Format
- command [–p] command-name [argument…]
- command [–V|–v] command-name
Description
command causes
the shell to suppress its function lookup and execute the given
command-name and
arguments as though they made up a standard command line. In most
cases, if
command-name is not the name of
a function, the results are the same as omitting
command.
If, however,
command-name is a special built-in
command, (see
sh), some unique properties
of special built-in commands do not apply:
- A syntax error in the command does not cause the shell running
the command to stop.
- Variable assignments specified with the special built-in command
do not remain in effect after the shell runs the command.
Options
- –p
- Searches for command-name using the
system default PATH variable.
- –v
- Writes a string indicating the path name or command that the shell
uses to invoke command-name.
- –V
- Writes a string indicating how the shell interprets command-name.
If command-name is a command, a regular
built-in command, or an implementation-provided function found using
the PATH variable, the string identifies it as such and includes the
absolute path name. If command-name is an
alias, function, special built-in command, or reserved word, the string
identifies it as such and includes its definition if it is an alias.
If the command is a tracked alias, the string identifies it as cached.
Examples
Typically, you use
command when
you have a command that might have the same name as a function. For
example, here's a definition of a
cd function
that not only switches to a new directory but also uses
lc to
list the contents of that directory:
function cd {
command cd $1
lc
}
Inside the function, use command to
get at the real cd. Otherwise, the cd function
would call itself in an infinite recursion.
Localization
command uses
the following localization environment variables:
- LANG
- LC_ALL
- LC_CTYPE
- LC_MESSAGES
- NLSPATH
See Localization for more
information.
Usage notes
command is
a built-in shell command.
Exit values
If you specified
–v,
possible exit status values are:
- 0
- Successful completion
- 1
- command could not find command-name,
or an error occurred
- 2
- Failure due to incorrect command-line argument
If you did not specify
–v,
possible exit status values are:
- 126
- command found command-name,
but failed to invoke it.
- 127
- An error occurred in the command or it could not find command-name.
Otherwise, the exit status of command is
the exit status of command-name.