On 11/21/16 11:32 PM, Mark Galeck wrote:

> "The list shall be 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".
> 
> Well, that is not how both dash and bash behave.  They do not search until
> an exec file with appropriate permissions is found.  They stop when a
> regular file or a symlink is found.  Then, if that does not refer to an
> executable with correct permissions, they do not continue but issue an error. 
>  

That's not quite true.  If bash searches for a name using $PATH, it will
prefer a file with the execute bits set even if there is a file without
the execute bits set earlier in the $PATH.  It will report a
non-executable error only there is no other file found via the $PATH
search.

You can test this by creating a file named 'ls' in, say, $HOME/bin,
adding $HOME/bin to the beginning of $PATH, and running `bash -c 'ls''.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to