delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/03/28/16:29:43

Date: Mon, 28 Mar 94 16:00:19 -0500
From: frank AT manua DOT gsfc DOT nasa DOT gov (Frank Chen)
To: Jonathan Ryshpan <jon AT halsp DOT hitachi DOT com>,
dave AT babel DOT ho DOT att DOT com (Dave Hayden 908- 946-1107)
Subject: Re: argv[0] problem (unwanted path in printout)
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu

>>Also, I think UNIX C runtime libraries DON'T put the full path name in
>>argv[0].  Argv[0] contains whatever the program that called exec()
>>puts in it.  On UNIX, ksh seems to put whatever the user typed, not
>>the fully qualified path.  I don't know about other shells.
>
>Some other Unix shells:
>	bash: full path name (e.g. /usr/jon/bin/hello)
>	csh:  full path name
>	sh:   what the user types (e.g. hello)
>
>This is the result of one test, so I wouldn't swear to it in court; 
>but I think it's correct.
>
Test result from SGI IRIX 4.0.5:
tcsh, csh, and sh all show whatever the user types.

However on shell scripts, if the script is in your search path but differ
from your current working directory, argv[0] will contain the full path
for all three shells when you just type the script name.(hello -> /path/hello)
If you type either relative path or absolute path name, result will be
what every you type(./hello -> ./hello, $HOME/bin/hello -> 
/usr/people/guest/bin/hello).
If you type 'hello' in the same directory as 'hello' script, both csh and
tcsh show 'hello' but sh shows './hello'. 
I don't know whether my setup in .cshrc/.tcshrc/.profile will affect the
result or not.

-Frank

====================================================================
Chih-Hung Chen(Frank), GSC/SAIC          <frank AT manua DOT gsfc DOT nasa DOT gov> 
SeaWiFS Data System      <http://seawifs.gsfc.nasa.gov/SEAWIFS.html>
NASA/GSFC Code 970.2              (301) 286-9531, fax:(301) 286-1775
Greenbelt, Maryland 20771                    


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019