Contents of argv[0]

Doug Gwyn gwyn at smoke.BRL.MIL
Wed Aug 16 13:56:16 AEST 1989


In article <9002 at attctc.Dallas.TX.US> jls at attctc.Dallas.TX.US (Jerome Schneider) writes:
>Are there any (proposed) standards for argv[0] syntax?

IEEE 1003.2 may have something to say about it, but the only portable-C
specification is that IF argc is greater than 0 AND IF argv[0][0] is not
the null character THEN argv[0] represents the "program name".  As you
see, a program name need not even be supplied by the implementation.

>If not, should a _portable_ application always rindex() argv[0] for a
>path delimiter before optionally (under DOS and OS half) converting the
>name to_lower()?

I don't think a "_portable_" application should use rindex() at all,
nor should it assume that tolower() (not to_lower()) is a meaningful
thing to do on environment-supplied text.  If you're going to display
argv[0] (which is about the only meaningful thing you can do with it),
why not just print the whole thing.  If you really need to keep the
name short and happen to KNOW how to parse pathnames into components,
then of course you could do that and print the result.  The function
used to do that is traditionally named simple().



More information about the Comp.lang.c mailing list