3

Let's say, I have the following structure:

/usr/bin/app
/home/me/bin/app

And $/usr/bin/app --version --> v1, $/home/me/bin/app --version --> v2.

So, when I execute some command, say $app --version, it returns v1, but my $which app gives me /home/me/bin/app, so, as I think, it must execute the second app, and return v2. Why doesn't it happen?

In other words does the construction $app equivivalent to $$(which app), and for which reason it doesn't apply ?

2
  • 2
    try deleting your app with hash -d app and add your app again
    – ardiyu07
    Commented May 16, 2013 at 9:11
  • thanks, that works! Suggest you to make the comment to be an answer, so I can accept it.
    – Necto
    Commented May 16, 2013 at 9:45

1 Answer 1

6

Since which takes the hashed value from the linux hash table, when you installed a new executable with the same name, the shell still continues to use the old table, so then it brings a conflict. Instead of using hash -d <appname> (which worked), you can also use rehash command I believe. (and you should also use zsh, it's very cool :) )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.