DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

command(C)


command -- execute a simple command

Syntax

command [ -p ] name [ argument ... ]

command [ -v | -V ] name

Description

command executes the command name together with its arguments.

command stops the shell looking for a function defined within it with the same name as the command name. This may be used to prevent a function from calling itself recursively (see ``Examples'').

If the command name is a special built-in utility (such as eval, exec, and set), any variable assignments do not remain in effect in the environment of the shell after the utility has finished executing. Also, syntax errors will not cause the shell to abort.

Using command to execute a command name that is not a shell function or a special built-in utility is identical to invoking name in its own right.

You can find out what type of command the current shell thinks name is by using the options -v or -V.

command accepts the following options:


-p
Use a default value for PATH that finds all the standard utilities.

-v
Print to the standard output:

-V
Prints the same information as -v in a more verbose form including the assumed category of name:

Exit values

command used with the -v or -V options has the following exit values:

0
successful completion

>0
name could not be found or an error occurred in command

Otherwise, command returns:


126
name was found but it could not be executed

127
name could not be found, or an error occurred in command
Any other value is the exit value returned by the command name.

Examples

Define a function cd() that prints the new working directory (note that command prevents this function from being recursive):
   cd()	{
   	command cd "$@" > /dev/null
   	pwd
   	}
Stop a special built-in utility from aborting the shell; for example when trying to redirect the standard output to a file that has the wrong permissions:
   command exec > file_with_mode_0000
Execute getconf(C) to get the default system path without assuming that PATH is already set up:
   command -p getconf CS_PATH

Limitations

command is available in ksh(C) only.

See also

ksh(C)

Standards conformance

command is conformant with:

ISO/IEC DIS 9945-2:1992, Information technology - Portable Operating System Interface (POSIX) - Part 2: Shell and Utilities (IEEE Std 1003.2-1992);
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003