Mark Galeck <mark_gal...@pacbell.net> wrote:

> Hello,
> the shell standard section on Command Search and Execution, says 
> command shall be searched for using the PATH environment variable as 
> described in XBD Environment Variables 
> and that section says the value of PATH is split into a list and 
> "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".

Shells without PATH hashing usually just test all possible PATHs by calling 
exec() and stop when they reached the end of the PATH list or when the exec() 
succeeded. The error code is usually the last encountered error.

The Bourne Shell introduced a PATH hash mechanism and behaves a bit different:

It checks all possible path names via stat() and remembers the first path name 
that is not a directory and that is executable for the shell user. The later 
is checked by calling EUID access(), in modern systems this is:

        faccessat(AT_FDCWD, name, X_OK, AT_EACCESS)

This method has a minor problem: it cannot detect whether a binary file 
containes executable code for a different CPU platform. So if you have such a 
file in your PATH before the expected binary, the expected binary will not be 
found.

As you see, this is still compatible with the standard text ;-)

Jörg

-- 
 EMail:jo...@schily.net                    (home) Jörg Schilling D-13353 Berlin
       joerg.schill...@fokus.fraunhofer.de (work) Blog: 
http://schily.blogspot.com/
 URL:  http://cdrecord.org/private/ 
http://sourceforge.net/projects/schilytools/files/'

Reply via email to