[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
wanted: ARGV standard extension
Hi!
After having been fooling around for a few dozen minutes with something
sh-ish like
if [ "$blahfoo" = "" ]
and wondering why it doesn't work, I just remembered that ARGV doesn't
support empty parameters. ARGGGG-V !
*
Do you remember the discussion on this subject on Usenet? As far as I can
recall, this discussion didn't come to a definite end, did it?
Several proposals have been made, and the one which seemed to be most
robust one looked like the following (if I remember correctly):
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.
_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"
^^^^^^^^^^
(see notes below)
A program which is aware of the new standard will notice the magic
word "NULL" in ARGV's value and will decode the argv[] indexes it
signals.
A program which is not aware of the new standard, but which is aware
of Atari's old ARGV standard will see spaces in place of empty
arguments. The spaces have been introduced to guarantee that
the parameters stay on their positions.
A totally unaware program (not aware of either standard) won't see
the ARGV at all; see below...
A few notes:
The format of the value of the "ARGV=" environment entry hasn't been
discussed to the last extend yet. We could also use some binary magic
instead of "NULL:". The positions of null arguments could also be
communicated bit-wise ("010010010") or bit-wise and packed (i.e. base 16,
like "A6"). Personally, I like the list form best ("1,3,4").
Non-ARGV-aware programs (those which read their command line from their
basepage) should see the parameters in the right place too.. Of course,
a space can't be inserted in place of an empty argument because spaces
separate words in the basepage's command line. I suggest substituting
empty args with the two characters "''" (two single quotes) in the basepage.
Those programs that use the value of ARGV= for other purposes (Mark
Williams C compiled programs) will conform/work as long as they're not
passed empty args. If someone tries to pass empty args to them from an
aware shell, these programs will lose. However, these programs would
also lose in this case if the (new) standard wouldn't exist (because
empty arguments are impossible resp. truncate the ARGV parameters in the
environment), so this is not really a problem. [Ian Lempore had once
pointed this out. He used to have good arguments in that usenet
discussion. He's (of course?) not on this list, so I'll "Cc:" this
article to him.]
I'd like to hear your comments here. A word from someone @ Atari would
be nice, too.
Thanks,
Michael
--
Internet: hohmuth@freia.inf.tu-dresden.de