Description of problem: If I run a program in a bash shell and then delete and try to run it again, bash complains that the file no longer exists! While this is true it is rather annoying when the deleted file was shadowing another binary further down PATH. One has to start a new shell in order to run it which is annoying. Version-Release number of selected component (if applicable): PackageKit-command-not-found-0.6.17 How reproducible: 100% Steps to Reproduce: 1. start a shell in recent Fedora default install $ mkdir -p ~/bin $ cat > ~/bin/myprog #!/bin/sh echo This is myprog $ chmod u+x ~/bin/myprog $ myprog This is myprog $ rm ~/bin/myprog $ myprog 2. $ sudo yum remove PackageKit 3. Repeat (1) Actual results: 1. bash: /home/liveuser/bin/myprog: No such file or directory 3. bash: myprog: command not found... Expected results: 1. bash: myprog: command not found...
This also happens with F15, and I have probably seen it on F14 too and maybe even earlier.
Isn't bash just calling the command-not-found callback erroneously? PackageKit doesn't do anything smart, it just runs when bash tells it to.
Bash is calling command not found handler whenever (it is defined and when) you try run a command which is not found. The problem is in way how bash is trying to found it. Bash is using hash table to remember commands already run. You can clear that hash table, don't use it all, but default is hash table turned on. That means, you run a command, bash will remember full location and then will try tu run it on that location. The strange thing here is; $ rm ~/bin/myprog $ myprog 2. I will expect here "command not found" message.
(In reply to comment #3) > The strange thing here is; > $ rm ~/bin/myprog > $ myprog > 2. > > I will expect here "command not found" message. I'm getting this message. You have three solutions; 1) turn off hash tables (set +h) 2) clear hash table (hash -d) 3) turn on option that will force lookup for binary when the binary is not found on location specified in hash table - look at man page (shopt -s checkhash) I will close this bug as notabug.
Did this behaviour change at some point in the not so distant past? I am pretty sure this was not always the case - I still assumed not needing to (run) rehash was one of the advantages of bash. Is the default for security reasons or to avoid superfluous stat'ing? It seems I should run "hash myprog" to workaround this.