How to get the pathname of the current executable?

David Elliott dce at smsc.sony.com
Wed Feb 14 05:10:22 AEST 1990


In article <1990Feb13.095913.29040 at hayes.fai.alaska.edu> wisner at hayes.fai.alaska.edu (Bill Wisner) writes:
>In article <5378 at buengc.BU.EDU>, bph at buengc (Blair P. Houghton) writes:
>>			       (someone please tell me
>>why which(1) reads the .cshrc...)
>
>Because which(1) is a csh script.

Chuckle.  Pretty good.

I don't think that's what Blair was asking.  Obviously he knows it's a
csh script, since it would be hard for him to know that it reads
.cshrc otherwise.

The question is: Why does which run without the -f option, which would
cause it *not* to read .cshrc?

I think that the answer is that it wants to handle aliases.

The problem is that this can also cause the path to be changed (people
who use remote shells know to define the path in .cshrc).  One
possibility to "fix" which would be to have it run with -f, check the
path for all possibilities, source the .cshrc, and then check for
aliases.  Of course, this has problems, too.

Personally, I prefer builtin commands for doing this job, like type in
sh and Tony Birnseth's builtin which for csh.

-- 
David Elliott
dce at smsc.sony.com | ...!{uunet,mips}!sonyusa!dce
(408)944-4073



More information about the Comp.unix.questions mailing list