Archive for March, 2008

The Shining $PATH

Friday, March 21st, 2008

The search-path algorithm for UNIX is broken, and has been broken for a long time.

$PATH is fine for specifying bin directories; in fact, there ought to be just one $PATH per host, which all processes can inherit, rather than users having to set such things in their dotfiles. $PATH isn’t obsolete, but it needs help.

The problem is with interpreting the order of the PATH variable. The historic algorithm, implemented by the first exec() and its descendants, is to search each of the dirs in $PATH, in the order in which they appear, until a file matching the provided command name is found, and then exec that file. It’s a simple algorithm: fast, easy to implement … but it’s also the cause of a whole genre of UNIX aggravations.
Read the rest of this entry »