Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: which command doesn't work
- X-seq: zsh-users 14193
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: which command doesn't work
- Date: Sat, 13 Jun 2009 12:46:21 -0700
- Cc: Cesar Romani <cesar.romani@xxxxxxxxx>
- In-reply-to: <200906131929.n5DJTDBY003149@xxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <200906131929.n5DJTDBY003149@xxxxxxxxxxxxxxxxxxx>
On Jun 13, 8:29pm, Peter Stephenson wrote:
} Subject: Re: which command doesn't work
}
} Cesar Romani wrote:
} > If my first command on the shell is:
} > zsh$ls -l |less
} > it takes the last version of less, namely:
} > zsh$which less
} > /c/Programmi/GnuWin32/bin/less
} >
} > But if my first command is:
} > zsh$which less
} > /usr/local/bin/less
} > and then
} > zsh$ls -l |less
} > it takes the correct version.
} > That's strange!
}
} If you replace "which less" with "rehash", does it also find the right
} version? That would be a workaround (but shouldn't be necessary).
Aha! I think I know what's going on.
Check this out:
% which less
/usr/bin/less
% mkdir /tmp/path
% touch /tmp/path/less
% chmod +x /tmp/path/less
% path=(/tmp/path $path)
% which less
/tmp/path/less
% less -V
less 382
Copyright (C) 2002 Mark Nudelman
less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Homepage: http://www.greenwoodsoftware.com/less
%
Note that /usr/bin/less executed even though which says /tmp/path/less is
found first.
So what's happening is that somewhere in Cesar's startup, the HASH_DIRS
option is causing all the files in /c/Programmi/GnuWin32/bin to be added
to the command hash table. *After* that, he prepends /usr/local/bin et al.
to $PATH, but the hash table doesn't rebuild itself when the path changes,
so the previously hashed location is still executing.
Either add a "rehash" after changing the path, or change the path sooner.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author