[Cialug] $PATH command resolution

Todd Walton tdwalton at gmail.com
Thu Jan 7 07:29:08 CST 2010


On Wed, Jan 6, 2010 at 9:54 PM, Colin Burnett <cmlburnett at gmail.com> wrote:
> `If the name is neither a shell function nor a builtin, and contains
> no slashes, bash searches each element of the PATH for a directory
> containing an  executable  file  by  that name.  Bash uses a hash
> table to remember the full pathnames of executable files.  A full
> search of the directories in PATH is performed only if the command is
> not found in the hash table.`
>
> I interpret that to mean if you call foo from /a/b/c then it
> 1) looks for /a/foo
> 2) looks for /a/b/foo
> 3) looks for /a/b/c/foo
> 4) iterates through $PATH, in order, looking for the first executable foo.

I'm pretty sure that's not the way that works.  I've only seen bash do
number 4, though this hash table business is new to me.  I'm not sure
what they mean by that.  How often does it refresh that hash table?

--
Todd


More information about the Cialug mailing list