Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: which command doesn't work



Bart Schaefer wrote:
> On Jun 12,  3:52pm, Cesar Romani wrote:
> }
> } I've installed zsh 4.3.10 on the MSYS environment.
>
> I don't recall MSYS being mentioned here before (in fact I'd never
> heard of it at all) so there may not be much we can do for you.

MSYS is like the Cygwin environment

> } $which -a less
> } /usr/local/bin/less
> } /bin/less
> } /c/Programmi/GnuWin32/bin/less
> }
> } The which command takes the last version of less, although that version
> } is located at the end in my PATH. And when I want to use less, the shell
> } takes the last version of it. Why?
>
> What does
>
>     ls -l $(which -a less)

zsh$ls -l $(which -a less)
-rwxr-xr-x 1 Romer Administrators 157931 Aug 25  2008 /bin/less
-rwxr-xr-x 1 Romer Administrators 169472 May 27 17:34
/c/Programmi/GnuWin32/bin/less
-rwxr-xr-x 1 Romer Administrators 342067 May 22 15:32 /usr/local/bin/less

> show you?  If zsh thinks one of those has execute permission and the
> others do not, it'll prefer the executable one even if the others
> are earlier in the path.  In fact if none of them appear to have
> execute permission it'll probably say "command not found".
>
> You might be able to get zsh to treat a .exe extension as equivalent
> to having execute permission if you configure such that it believes
> it's in the Cygwin environment.

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!

Many thanks in advance,
Cesar



Messages sorted by: Reverse Date, Date, Thread, Author