Path: utzoo!attcan!uunet!husc6!mailrus!tut.cis.ohio-state.edu!bloom-beacon!gatech!purdue!i.cc.purdue.edu!j.cc.purdue.edu!pur-ee!uiucdcs!bradley!bucc2!brian From: brian@bucc2.UUCP Newsgroups: comp.unix.wizards Subject: Re: Finding where an executable was run Message-ID: <15200004@bucc2> Date: 16 May 88 16:11:00 GMT References: <4527@hoptoad.uucp> Lines: 29 Nf-ID: #R:hoptoad.uucp:4527:bucc2:15200004:000:1266 Nf-From: bucc2.UUCP!brian May 16 11:11:00 1988 > /* Written 4:25 pm May 11, 1988 by sun.uucp!limes in bucc2:comp.unix.wiza */ > In article <4527@hoptoad.uucp> gnu@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@seas.ucla.edu (309) 677-2230 ICBM: 40 40' N 89 34' W