[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: wanted: ARGV standard extension
> If the command line does _not_ contain empty arguments,
> the old ARGV standard applies; there are no additions. This is
> for maximal backwards compatibelity with old (unaware) applications.
I think this is an important thing to keep. Ian's \1 quoting suggestion
is a good one, but unfortunately incompatible in 1 case (namely, when
you're already passing \1 as the first character). Admittedly, this
seems like a very rare thing; but one can imagine programs (e.g. tr)
which might want to get binary arguments.
> _If_ (and only if) there are empty arguments, they're substituted
> by single spaces, and their position in argv[] is signaled thru
> the value of the "ARGV=" environment variable (which was
> reserved by Atari's earlier standard for future usage). Example:
> foo bar '' '' blah '' frob
> results in the following being appended to the child's environment:
> "ARGV=NULL:2,3,5\0foo\0bar\0 \0 \0blah\0 \0frob\0\0"
Sounds good to me. I like the list form of the NULL: part, too, rather
than using a bit array (especially since there are likely to be few empty
arguments in any given argument list).
I think such a list can be parsed in just 1 pass through the whole argument
list, plus 1 second pass through just the "NULL:2,3,5" list. You
parse the whole list the first time without worrying which arguments are
null; then you step through the NULL list and write 0 into the first bytes
of any NULL arguments. This shouldn't add much overhead to the ARGV
code. Ian: does that take care of your objection? Or am I overlooking
something?
(pedantic aside: "NULL" may not be the best keyword; maybe "NIL" would be
better, since the arguments aren't NULL pointers, they're pointers to empty
strings.)
These statements shouldn't be taken as any kind of "official" comments
from Atari; that will have to come later. This is just my opinion.
Eric