On Mon, Dec 23, 2024 at 8:32 PM George at Clug <[email protected]> wrote:
> [...]
> > eben@cerberus:~$ type command
> > command is a shell builtin
>
> https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
>
> https://www.gnu.org/software/bash/manual/html_node/Bash-Builtins.html
>
> command
>
> command [-pVv] command [arguments …]
>
> Runs command with arguments ignoring any shell function named command.
> Only shell builtin commands or commands found by searching the PATH are
> executed. If there is a shell function named ls, running ‘command ls’ within
> the function will execute the external command ls instead of calling the
> function recursively. The -p option means to use a default value for PATH
> that is guaranteed to find all of the standard utilities. The return status
> in this case is 127 if command cannot be found or an error occurred, and the
> exit status of command otherwise.
>
> If either the -V or -v option is supplied, a description of command is
> printed. The -v option causes a single word indicating the command or file
> name used to invoke command to be displayed; the -V option produces a more
> verbose description. In this case, the return status is zero if command is
> found, and non-zero if not.
>
> $ command --help
> command: command [-pVv] command [arg ...]
> Execute a simple command or display information about commands.
>
> Runs COMMAND with ARGS suppressing shell function lookup, or display
> information about the specified COMMANDs. Can be used to invoke commands
> on disk when a function with the same name exists.
>
> Options:
> -p use a default value for PATH that is guaranteed to find all of
> the standard utilities
> -v print a description of COMMAND similar to the `type' builtin
> -V print a more verbose description of each COMMAND
>
> Exit Status:
> Returns exit status of COMMAND, or failure if COMMAND is not found.
>
> "If there is a shell function named ls, running ‘command ls’ within the
> function will execute the external command ls instead of calling the function
> recursively."
> Is this the main point to command? "will execute the external command ls
> instead of calling the function recursively"
Greg provided the link to the documentation:
The "command" command's base functionality is specified by POSIX:
<https://pubs.opengroup.org/onlinepubs/9799919799/utilities/command.html>
And following the link:
DESCRIPTION
The command utility shall cause the shell to treat the arguments as a
simple command, suppressing the shell function lookup that is described
in 2.9.1.4 Command Search and Execution, item 1c.
> What is the difference between 'execute' and 'calling' ?
>
> Maybe "execute' does not return any exit value from the program being
> executed?
Jeff