Changing default setting of bash's hash table?

Kevin Kofler kevin.kofler at chello.at
Sat Aug 20 13:49:00 UTC 2011


Roman Rakus wrote:
> Maybe the subject is a bit misleading, I will clarify it.
> 
> Bash is using hash table to remember locations of executed commands.
> Whenever you try to run a command bash looks in hash table. When the
> command is found in table then bash will you full path name as it is in
> the table.
> 
> However there is a problem when the command moved (or is deleted). Bash
> by default is not checking if the command is really on the location. But
> there is bash option that will force bash to check if the command really
> exists. Man page says:
> checkhash
> If set, bash checks that a command found in the hash ta‐
> ble exists before trying to execute it. If a hashed
> command no longer exists, a normal path search is per‐
> formed.
> 
> I have a question, if it is worth to enable this option by default? It
> will not confuse some people, but can increase disk searching. Comments
> welcome.

It will only help if the first match in the search path is removed, it will 
still not do the right thing if a new match is prepended to the search path.

IMHO, this whole hashing should not be done in interactive shells at all. 
The bottleneck is going to be the user running the commands anyway. I can 
see how it speeds up scripts, but it's just confusing and useless in 
interactive operation.

        Kevin Kofler



More information about the devel mailing list