[Cialug] $PATH command resolution

Todd Walton tdwalton at gmail.com
Thu Jan 7 10:41:24 CST 2010


On Thu, Jan 7, 2010 at 10:20 AM, Zachary Kotlarek <zach at kotlarek.com> wrote:
> On cache misses it checks the disk again to see if you added anything but
> it never resets the hash table or removes invalid entries without manual
> intervention.
>
> The hash table is not persistent across bash instances -- it is reformed each
> time bash is launched as needed. If you always call programs by their
> absolute path it will never be populated.
>
> You can see the current cache-hit stats with:
>        hash
>
> You can reset the hash table manually with:
>        hash -r
>
> Or remove a specific item with:
>        hash -d unqualifed_exec_name
>
> Or if you launch bash with -h:
>        bash -h
> It will not form a hash table and instead will do regular $PATH lookups all
> the time.
>
> Generally there's no reason to reset the hash table; unless you're moving
> or deleting executables it won't ever be wrong, and it's faster, particularly
> if there's anything non-local in your $PATH.

Fascinating!  Thank you, Zach, for that explanation.

--
Todd


More information about the Cialug mailing list