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: Giuseppe Scrivano
Subject: Re: [PATCH] Ensure the command found in the hash table exists, not only on POSIXLY_CORRECT
Date: Thu, 07 Jan 2010 23:30:45 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.90 (gnu/linux)

Thanks for your answer.


Chet Ramey <chet.ramey@case.edu> writes:

>> I have a question: how bash should behave in the case you have:
>> 
>> -------------------------------------------
>> export PATH=a:b:$PATH
>> 
>> mkdir a b
>> 
>> cat > b/prog.sh << EOF
>> echo b/prog.sh
>> EOF
>> 
>> chmod +x b/prog.sh
>> 
>> prog.sh
>> 
>> cat > a/prog.sh << EOF
>> echo a/prog.sh
>> EOF
>> 
>> chmod +x a/prog.sh
>> 
>> prog.sh
>> -------------------------------------------
>> 
>> 
>> Which prog.sh should be used in this case?  a/prog.sh or b/prog.sh?  The
>> former has a higher precedence in PATH but the latter is the hashed
>> value.
>
> The hashed value should be preferred as long as it exists.  If you're
> concerned about this being a problem, run `hash prog.sh' after creating
> it.

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.

Cheers,
Giuseppe




reply via email to

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