Finding where an executable was run

brian at bucc2.UUCP brian at bucc2.UUCP
Tue May 17 02:11:00 AEST 1988


> /* Written  4:25 pm  May 11, 1988 by sun.uucp!limes in bucc2:comp.unix.wiza */
> In article <4527 at hoptoad.uucp> gnu at hoptoad.uucp (John Gilmore) writes:
> >If exec() would pass this value to the executed program, say as
> >argv[-1], then a program could reliably know its own name, and apply a
> >simple transformation to it to find its data files (e.g. for program
> >"XXXXXX/foo", its data files are found in "XXXXXX/lib/foo/whatever").
> 
> In Turbo-C, Borland passes the complete path name of the program
> executed as argv[0].  This may be specific to Turbo-C, or may be
> general across MS-DOS.  Are there any programs that this would break?

  I believe this is general to MS-DOS, since Microsoft C does the same
thing. It is annoying when you want to use the program name in error
messages, like:

	fprintf(stderr, "%s: %s\n", argv[0], errmsg);

  Not only do you get the full pathname, but it's probably in uppercase
as well...


...............................................................................

  When the going gets weird, the weird turn pro.

  Brian Michael Wendt       UUCP: {cepu,ihnp4,uiucdcs,noao}!bradley!brian
  Bradley University        ARPA: cepu!bradley!brian at seas.ucla.edu
  (309) 677-2230            ICBM: 40 40' N  89 34' W



More information about the Comp.unix.wizards mailing list