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

RE: PATCH: POSIX exit codes (not quite Re: status codes on Dec OSF)

> > There is another effect of this:  If there are two files in the
> path with
> > the same name, bash will always attempt to execute the first
> one and fail
> > with 126/"no such file", but zsh will keep searching and either execute
> > the second one or report 127/"command not found".
> >
> I guess, zsh's behaviour is more appropriate:
> [PATH search]
> The list is searched from beginning to end, applying the filename to each
> prefix, until an executable file with the specified name and appropriate
> execution permissions is found.

On the second thought, may be zsh is wrong here. It depends on the
definition of "appropriate execution permissions".  It may be understood as
"if file can be executed" (what zsh does currently). But I suspect, that it
actually meant "stat.st_mode & (S_IXUSR|S_IXGRP|S_IXOTHR)". I.e. file with
any executable bit set.

Current zsh behaviour may lead to unexpected (inappropriate) command
execution. Consider:

bor@itsrm2% ll /usr/sbin/pkgadd
-rwx------   1 root     sys       397793 Nov 18  1998 /usr/sbin/pkgadd*
bor@itsrm2% pkgadd
zsh: permission denied: pkgadd
bor@itsrm2% cat > ~/bin/pkgadd
#! /bin/sh

echo Pkgadd here!
bor@itsrm2% chmod +x ~/bin/pkgadd
bor@itsrm2% pkgadd
Pkgadd here!
bor@itsrm2% print $path
/tools/override/bin /usr/bin /usr/sbin /opt/bin /usr/ccs/bin /usr/ucb
/tools/bin /opt/nsr /usr/dt/bin /usr/bin/X11 /opt/xms/bin /opt/xms-menu/bin
/opt/Xprint/cmd /opt/Xprint/mercator/cmd /opt/lib/tele/bin /u1/nerv/bin
bor@itsrm2% ll =pkgadd
-rwxr-xr-x   1 bor      sinix         30 Jun 27 11:11 /home/bor/bin/pkgadd*

Any real reasons to retain current zsh exaustive path search?


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