Thanks for your answer.
Chet Ramey <chet.ra...@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