bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Ensure the command found in the hash table exists, not only


From: Chet Ramey
Subject: Re: [PATCH] Ensure the command found in the hash table exists, not only on POSIXLY_CORRECT
Date: Thu, 07 Jan 2010 22:39:03 -0500
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0

On 1/7/10 5:30 PM, Giuseppe Scrivano wrote:

> the code I have attached is just a test case that actually, AFAICS,
> can't be fixed without change its code.  This situation can be present
> in a shell script that potentially can rely on the PATH elements
> precedence.
> 
> Is there a way to disable commands hashing at all?  I couldn't find it.

There is.  Look at `set -h'.

Since this only happens when you run a command found using a PATH lookup,
causing it to be hashed, then explicitly create a command of the same
name and install it in another directory in PATH, I recommend that you
run `hash -r' after you install the second command.  This will avoid the
problem while retaining the benefits of hashing.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]