Subject: Re: /usr/bin/which is a csh script!!?!
To: David Laight <email@example.com>
From: Jim Bernard <firstname.lastname@example.org>
Date: 05/02/2003 07:56:32
On Fri, May 02, 2003 at 09:30:25AM +0100, David Laight wrote:
> > I've been using which(1) (/usr/bin/which) on a daily basis for around
> > 23 years. I currently use ksh as my shell. There is no builtin which
> > in ksh or sh.
> And there is no 'type' builting in csh!
> /usr/bin/which will give the wrong answer if there are shell functions
> or aliases lurking.
That depends on what answer you're seeking. Which can actually be handy
in the specific case that you are _not_ using csh, if you already know that
foo is, say, a shell function that eventually executes some program named
foo that is found in PATH, and you want to know "which version of that program
is ultimately going to be executed when I type foo?" (A better solution is
"whereis -p", but that's not portable, and it's easier to type "which".)