The following log shows that "command -v" prints the name of a shell
function even though the man page says that shell functions are
supposed to be excluded from the search.
$ foo() { echo fjdskfjs ; }
$ foo
fjdskfjs
$ command -v foo
foo
$ echo $?
0
$ command foo
bash: foo: command not found
$ echo $?
127
command [-pVv] command [arg ...]
Run command with args suppressing the normal
shell function lookup. Only builtin commands
or commands found in the PATH are executed.
[...] If either the -V or
-v option is supplied, a description of com-
mand is printed. The -v option causes a
single word indicating the command or file
name used to invoke command to be displayed;
[...] If the -V or -v option is sup-
plied, the exit status is 0 if command was
found, and 1 if not. If neither option is
supplied and an error occurred or command
cannot be found, the exit status is 127.
Otherwise, the exit status of the command
builtin is the exit status of command.
Matthias Klose wrote: The man page does not say that, though it's not obvious. Rather than specify two different builtins, POSIX chose to standardize `command' with two essentially independent modes. When used to run a command, it skips shell function lookup. When invoked with `-v' or `-V', it behaves like `type', and shell functions are included. If you look at the POSIX description of `-v' and `-V', you'll see that shell functions are explicitly included. Chet