[Cialug] $PATH command resolution

Zachary Kotlarek zach at kotlarek.com
Thu Jan 7 10:20:02 CST 2010


On Jan 7, 2010, at 7:29 AM, Todd Walton wrote:

> 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?



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.

	Zach

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2746 bytes
Desc: not available
Url : http://cialug.org/pipermail/cialug/attachments/20100107/8ae2c42d/attachment.bin 


More information about the Cialug mailing list