`which' in csh/Ultrix 4.1

Juergen Wagner gandalf at csli.Stanford.EDU
Tue Mar 5 22:37:00 AEST 1991


There seems to be some weirdness with `which' under Ultrix 4.1.
Here is the story:

A long time ago, I wrote a "which" of my own, a program which also
told me about multiple occurrences of files, which followed symbolic
links, etc. (if given the proper options). This morning, I compiled
that program under Ultrix 4.0 (on a DecStation 3100) to see how it
worked. The result was the following (imagine, bin/which were my
personal 'which'):

	foo% rehash
	foo% which which
	/u/gandalf/bin/which
	foo% which -a which

At this point, I expected to see /u/gandalf/bin/which and /usr/ucb/which
appear on my screen. Aaarrggh! What happened was

	No -a in /u/gandalf/bin/which /usr/ucb /usr/bin /bin ...
	/u/gandalf/bin/which

Ok. Trying to find out what's going on, I noticed that there were
actually three "which"s around: my own, the /usr/ucb one, ...and...
a built-in which os Ultrix' csh.

Great, I thought, why not make it a built-in? I can always rename my
own "which" to "Which".

What seemed to be a little strange, however, was how the built-in
"which" behaved when I tried it on some well-known programs:

	foo% which ls
	No ls in ....			Yes, there is /bin in my path!
	foo% which nslookup
	/usr/ucb/nslookup		but /usr/local/bin comes first
					in my path, and there *IS* an
					nslookup, too.

Does anybody have any comments on this? I am not sure whether the
behavior of "which" described above is a bug or a feature... besides,
it is not documented as a built-in.

--Juergen Wagner (gandalf at csli.stanford.edu)

PS: Please, copy my e-mail address on any followups since I do not
    read this newsgroup regularily.



More information about the Comp.unix.shell mailing list