I have a question about how the PATH environment variable works.
I wrote a script in $HOME/bin/gvim.
I want it to be called instead of /usr/bin/gvim,
so I've placed it before in the PATH.
However, it is still the old one that is found.
If I open an other terminal, I have the desired effect: the script in $HOME/bin is found
I don't understand how it's possible to have two terminals where the PATH variable is the same, echo $PATH outputs the same thing, but the two don't find the same script.
Could anyone explain me the subtlety I'm missing here?
Thanks in advance.
Strange. On a hunch, try hash -l. You set your new path without logging out, but a new shell works like you want. It the old path is hashed, it will take precedence.
A lot of shells cache the results of a PATH search so that they do not continually rescan all of the directories on the PATH looking for stuff. Most of the time this speeds stuff up nicely. But sometimes those caches become a pain. My solution, which I admit is extreme, is to restart the shell. So say I'm running ksh. I do this:
exec ksh
This causes the shell to replace itself with a new copy. ksh calls this particular feature "tracked aliases" and I think that "unalias gvim" would work, but I actually never have tried it. I just restart the whole shell.