command is a bash-builtin, that allows for finding aliases and functions (which may or may not use programs installed in $PATH).
$ type -a command
command is a shell builtin
command is /usr/bin/command
dave @ [ bahamas10 :: (Darwin) ] ~ $ command -v colordiff # a function
colordiff
dave @ [ bahamas10 :: (Darwin) ] ~ $ command -v chomd # an alias
alias chomd='chmod'
So, to get the output we want we need to call the command line tool explicitly. Since that's bad practice, we should use the command command.
dave @ [ bahamas10 :: (Darwin) ] ~ $ command command -v colordiff
colordiff
dave @ [ bahamas10 :: (Darwin) ] ~ $ command command command -v colordiff
colordiff
??? the command command still calls the builtin, and never the command intalled on the operating system.
in response to @dualbus on https://twitter.com/bahamas10_/status/469529051443789824
this can still be fooled, albeit in a highly contrived manner.
1 make a file in your cwd, which is NOT in your
$PATH, that has executable permissions2 ensure the command does not show up when running the
command -vcommand (this is expected and proper)3 define a function with the same name as the executable file in your cwd,
foobar4 observe that the check returns successful, even though there is no program named
foobarin your$PATH