[Cialug] $PATH command resolution

Kenneth Younger kyounger at gmail.com
Wed Jan 6 22:05:35 CST 2010


Colin: The *bash* man page was probably the only one I didn't look through.
duh.

Jeff: Is that also why "php is hashed (/usr/bin/php)" is returned when `type
php` is run?

Thanks both.

On Wed, Jan 6, 2010 at 10:00 PM, Jeffrey Ollie <jeff at ocjtech.us> wrote:

> On Wed, Jan 6, 2010 at 9:54 PM, Colin Burnett <cmlburnett at gmail.com>
> wrote:
> > From the bash man page:
> >
> > `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
>
> Bash will not look in any of these directories.
>
> > 4) iterates through $PATH, in order, looking for the first executable
> foo.
>
> Yep.  The hash table is only an optimization.
>
> --
> Jeff Ollie
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> http://cialug.org/mailman/listinfo/cialug
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cialug.org/pipermail/cialug/attachments/20100106/7c33e548/attachment-0001.htm 


More information about the Cialug mailing list