On Tue, Dec 24, 2024 at 09:28:43 +1100, George at Clug wrote: > Shows how much about Linux I know, I had never previously heard about the > command called command. > > An Internet search was not great since "command" is such a common term, > however I managed to find some info using the usual Linux 'get help' options. > Maybe there is more detailed info out there somewhere? > > $ man command > No manual entry for command > > $ command --help > command: command [-pVv] command [arg ...] [...]
The "command" command's base functionality is specified by POSIX: <https://pubs.opengroup.org/onlinepubs/9799919799/utilities/command.html> Specific shells (like bash or dash) may add additional functionality to it. I'm not specifically aware of anything added by bash, but that doesn't mean there isn't anything. The bash reference manual would be the authoritative reference, if you want to comb through that. The bash man page is usually close enough, and is more readily available. Bash has other commands, such as "type", which extend the introspection parts of "command". For example, "type -a echo" may be informative, especially on systems like Solaris where there are potentially several different "echo" programs in different directories, and the ordering of directories in PATH determines which one is used. POSIX's "command" only prints the first thing found, and has no option like "-a" to print more things. The most common use of "command" is writing a wrapper function: ls() { if [ -t 1 ]; then command ls --color -F "$@" else command ls "$@" fi } Without "command ls", the function would recurse infinitely. Since "command" suppresses function lookups, it prevents the function from calling itself, without requiring you to write "/bin/ls" or some other path that may or may not be correct.