[X-Unix] The which command lies?

Steve Morris barbershopsteve at gmail.com
Mon Feb 15 19:01:39 PST 2010


I just discovered that the which command on my snow leopard OS is lieing to
me. I have had a succession of problems with installing various versions of
perl which then fail with cpan, all in all a frustrating experience. That
means I have perl installed in multiple places. I have been trying to make
the one I like the default. I tried using alias, changing the path, putting
a symbolic link to my preferred version in my ~/bin directory (which is
always at the front of my $PATH) and the "which" command keeps telling me
that /usr/bin/perl is the magic one that will be executed. I finally got
suspicious and tried to get perl to tell me where it lived. perl -e 'print
"$0\n";' was unhelpful; perl -e '"print $^X\n";' was unhelpful. Finally I
remembered @INC and tried these two commands which should give identical
results if 'which' can be trusted:

`which perl` -e 'print "@INC\n";'
 perl -e 'print "@INC\n";'

Instead these commands gave me totally different results indicating two
different installations of perl. It turns out that my redirections were
working but "which" wasn't seeing them.

What the heck is wrong with the "which" command on OSX? Why do "bash" and
"which" disagree on the actual path of the command to run? What is the point
of having a "which" command if it doesn't match.

Regards,

Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserver.themacintoshguy.com/pipermail/x-unix/attachments/20100215/b06aae9b/attachment.htm>


More information about the X-Unix mailing list