home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!fulcrum!its!silver.its.bt.co.uk!jvt
- From: jvt@its.bt.co.uk (John Trickey)
- Newsgroups: comp.sys.atari.st.tech
- Subject: Re: Problems with ARGV
- Message-ID: <1992Jul30.171118.2682@its.bt.co.uk>
- Date: 30 Jul 92 17:11:18 GMT
- References: <92211.111512RESCHKE@DMSWWU1A.UNI-MUENSTER.DE> <1992Jul29.130755.27902@mks.com> <1992Jul29.221225.24054@mnemosyne.cs.du.edu>
- Sender: @its.bt.co.uk
- Organization: BT Group Computing Unix Support, Birmingham, UK
- Lines: 53
-
- In article <1992Jul29.221225.24054@mnemosyne.cs.du.edu> ilepore@nyx.cs.du.edu (Ian Lepore) writes:
- >
- > > ARGV doesn't allow passing empty arguments
- > > use another env var to pass the position of the empty args
- >
- > I don't like it. It sounds needlessly complicated to create a whole
- >'nother env var for this.
-
- Yes and no. I don't see the point of duplicating the information.
-
- > I have two variations on an idea for coping with this. The first variation
- >assumes that we never pass binary values in the ARGV. (IE, isprint() is
- >TRUE for all chars appearing in the args in the ARGV area.) In this case,
- >I'd recommend using \001 as a placeholder for an empty arg. Using this,
- >
- > grep "" *.c
- >
- > would be passed as ARGV=\0grep\0\1\0*.c\0\0. If my assumption is invalid,
- >and folks do pass binary data in ARGV, then use an escape system where an
- >empty arg is \1\1, but a true binary 1 is \1\2. (You could even extend
- >this to allow passing binary zeros, escaped as \1\3 for example.)
- >
- > Thoughts?
-
- Am I missing something? It seems all too easy for me. Why not pass ARGC ?
-
- so in the above example:
-
- ARGC="3"
-
- (assuming the cli does not interpret the *.c) and
-
- ARGV="grep\0\0*.c\0"
-
- (yes there are 2 \0 's on the end --- remember a str is terminated by \0)
-
- then the startup code mimics
- tmp = argc = atoi(getenv("ARGC"));
- while (--tmp) {
- . argv processing
- .
- }
- . argv tidy up
- main(argc, argv);
-
- and you can pass null strings, binary data (as long as it does not
- contain \0) as much as you like.
-
- --
- John Trickey <jvt@its.bt.co.uk>
- Voice: +44 21 524 8200 Fax: +44 21 553 6120
- (Home) <john@its.bt.co.uk> || <john@g4rev.ampr.org> || G4REV @ GB7FLG
- +44 21 308 8892
-