Red Hat Bugzilla – Bug 10250
RHL 6.1 "which" command and man page are dangerously erroneous.
Last modified: 2008-05-01 11:37:54 EDT
The man page says "it prints to stdout the full path of the executables
that would have been executed when [SHOULD BE "if"] this argument had
been entered at the shell prompt". But if "kill" is entered at the bash
shell prompt, the reported "/bin/kill" will NOT be executed, because
bash will run it's own kill command which has different options.
Either the command or the man page is wrong. If the command can't be
changed, then the man page should provide warning in both the
"Description" and the "Bugs" sections.
The nuance of difference between "if" and "when" is carefully noted, but
hardly seems to be a crucial point.
Reading further in the man page shows how to use
alias which='alias | which --tty-only --read-alias --show-tilde --show-dot'
in order to detect (at least) aliased commands, and a little thought should
provide a mechanism for detecting builtins as well, if that's your pleasure.
Meanwhile, the existing which(1) is superior to the traditional implementation
of which in a csh script, and the behavior is dictated more by conformance with
tradition than logic.