Contents of argv[0]

Bob McGowen Wyse Technology Training bob at wyse.wyse.com
Wed Aug 16 03:13:53 AEST 1989


In article <1681 at crdgw1.crd.ge.com> davidsen at crdos1.UUCP (bill davidsen) writes:
>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?  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()?
>
>  If the program is portable you would have no way to know what the
>path delimiter is... since the set includes "/" for UNIX, "\" for
>MS-DOS, ":[]" for VMS, ":<>" for TOPS, etc. Since some systems allow
---some deleted---

How about proposing a new function to be called basename(), obviously
coded for the environment which the compiler was running under?  It
would return a pointer to a string which would be the name of the
program.

For example, in shell programming where root (with no current dir in
the PATH) must run the script as {absolute|relative path}name, $0 will
include the path used to invoke the script.  I have started using the
basename command to guarantee that the name I use in usage/error
messages is just the name of the script.

Bob McGowan  (standard disclaimer, these are my own ...)
Customer Education, Wyse Technology, San Jose, CA
..!uunet!wyse!bob
bob at wyse.com



More information about the Comp.lang.c mailing list