The `which' command should be quiet when finding nothing. Which is also defined as a shell alias for type -path in /etc/bashrc, so the behaviour can be quite unpredictable, because the shell alias version IS quiet as it should be. which-1.0-11 is not. Examples, where the file foobar does not exist: The shell version: $ /bin/rm `which foobar` rm: too few arguments Try `rm --help' for more information. The external version!!!: $ su somebody # or bash $ /bin/rm `which foobar` rm: cannot remove `/usr/bin/which:': No such file or directory rm: cannot remove `no': No such file or directory rm: cannot remove `foobar': No such file or directory rm: cannot remove `in': No such file or directory rm: cannot remove `(/usr/local/bin:/usr/bin:/usr/local/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/X11R6/bin:/usr/local/bin)': No such file or directory. Suggested fix: Remove the which binary and the /etc/bashrc alias and create a scripts, /usr/bin/which, which says: #!/bin/bash type -path "$@"
I have verified these to occur in a stock install of Red Hat 6.0.
This is also fixed as of which-2.x. Version 2 writes to stderr: ~>/bin/rm `which foobar` /usr/bin/which: no foobar in (.:~/bin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/X11R6/bin:/usr/X11R6/bin:/opt/kde/bin:/usr/local/share/prototype/scripts:/usr/local/java/bin) /bin/rm: too few arguments Try `/bin/rm --help' for more information.
which-2.8 is in Raw Hide.