1command(1)                       User Commands                      command(1)
2
3
4

NAME

6       command - execute a simple command
7

SYNOPSIS

9   /usr/bin/command
10       command [-p] command_name [argument]...
11
12
13       command [-v | -V] command_name
14
15
16   ksh93
17       command [-pvxV] [command_name [argument...]]
18
19

DESCRIPTION

21       The command utility causes the shell to treat the arguments as a simple
22       command, suppressing the shell function lookup.
23
24
25       If the command_name is the same as the  name  of  one  of  the  special
26       built-in utilities, the special properties do not occur. In every other
27       respect, if command_name is not the name of a function, the  effect  of
28       command (with no options) are the same as omitting command.
29
30
31       The  command utility also provides information concerning how a command
32       name is interpreted by the shell. See -v and -V.
33
34   ksh93
35       Without the -v or -V option, command executes command_name  with  argu‐
36       ments specified by argument, suppressing the shell function lookup that
37       normally occurs. In addition, if command is a special built-in command,
38       the  special  properties  are removed so that failures do not cause the
39       script that executes it to terminate.
40
41
42       If the -v or  -V  options  are  specified,  command  is  equivalent  to
43       whence(1).
44

OPTIONS

46       The following options are supported by /usr/bin/command:
47
48       -p    Performs  the  command search using a default value for PATH that
49             is guaranteed to find all of the standard utilities.
50
51
52       -v    Writes a string to standard output that  indicates  the  path  or
53             command that is be used by the shell, in the current shell execu‐
54             tion environment to invoke command_name, but does not invoke com‐
55             mand_name.
56
57                 o      Utilities,  regular  built-in utilities, command_names
58                        including a slash character, and  any  implementation-
59                        provided functions that are found using the PATH vari‐
60                        able is written as absolute path names.
61
62                 o      Shell functions, special built-in  utilities,  regular
63                        built-in  utilities not associated with a PATH search,
64                        and shell reserved words are  written  as  just  their
65                        names.
66
67                 o      An  alias is written as a command line that represents
68                        its alias definition.
69
70                 o      Otherwise, no output is written and  the  exit  status
71                        reflects that the name was not found.
72
73
74       -V    Writes  a  string  to standard output that indicates how the name
75             specified in the  command_name  operand  is  interpreted  by  the
76             shell,  in  the current shell execution environment, but does not
77             invoke command_name.  Although  the  format  of  this  string  is
78             unspecified,  it  indicates  in which of the following categories
79             command_name falls and include the information stated:
80
81                 o      Utilities, regular built-in utilities, and any  imple‐
82                        mentation-provided  functions that are found using the
83                        PATH variable is identified as such  and  include  the
84                        absolute path name in the string.
85
86                 o      Other shell functions is identified as functions.
87
88                 o      Aliases  are  identified  as aliases and their defini‐
89                        tions are included in the string.
90
91                 o      Special built-in utilities are identified  as  special
92                        built-in utilities.
93
94                 o      Regular  built-in utilities not associated with a PATH
95                        search is identified as regular built-in utilities.
96
97                 o      Shell reserved words are identified as reserved words.
98
99
100   ksh93
101       The following options are supported by ksh93 command:
102
103       -p    Causes a default path to be searched rather than the one  defined
104             by the value of PATH.
105
106
107       -v    Equivalent to:
108
109               whence command [argument ...]
110
111
112
113
114       -V    Equivalent to:
115
116               whence -v command [argument ...]
117
118
119
120
121       -x    If  command  fails  because  there  are too many arguments, it is
122             invoked multiple times with a subset of  the  arguments  on  each
123             invocation.  Arguments  that  occur  prior to the first word that
124             expand to multiple arguments and arguments that occur  after  the
125             last  word  that expands to multiple arguments are passed on each
126             invocation. The exit status is the maximum invocation  exit  sta‐
127             tus.
128
129

OPERANDS

131       The following operands are supported:
132
133       argument        One  of  the  strings  treated  as  an argument to com‐
134                       mand_name.
135
136
137       command_name    The name of a utility or a special built-in utility.
138
139

EXAMPLES

141       Example 1 Making a Version of cd That Always Prints Out the New Working
142       Directory
143
144
145       The  following example takes a version of cd that always prints out the
146       new working directory exactly once:
147
148
149         cd() {
150              command cd "$@" >/dev/null
151              pwd
152         }
153
154
155
156       Example 2 Starting Off a secure shell script in Which the Script Avoids
157       Being Spoofed by Its Parent
158
159
160       The  following  example  starts  off a secure shell script in which the
161       script avoids being spoofed by its parent:
162
163
164         IFS='
165         '
166         #    The preceding value should be <space><tab><newline>.
167         #    Set IFS to its default value.
168         \unalias -a
169         #    Unset all possible aliases.
170         #    Note that unalias is escaped to prevent an alias
171         #    being used for unalias.
172         unset -f command
173         #    Ensure command is not a user function.
174         PATH="$(command -p getconf _CS_PATH):$PATH"
175         #    Put on a reliable PATH prefix.
176         #    ...
177
178
179
180
181       At this point, given correct permissions on the directories  called  by
182       PATH, the script has the ability to ensure that any utility it calls is
183       the intended one. It is being very cautious  because  it  assumes  that
184       implementation  extensions  can  be present that would allow user func‐
185       tions to exist when it is invoked. This capability is not specified  by
186       this  document,  but it is not prohibited as an extension. For example,
187       the ENV variable precedes the invocation of  the  script  with  a  user
188       startup  script.  Such  a  script  could  define functions to spoof the
189       application.
190
191

ENVIRONMENT VARIABLES

193       See environ(5) for descriptions of the following environment  variables
194       that  affect  the execution of command: LANG, LC_ALL, LC_CTYPE, LC_MES‐
195       SAGES, and NLSPATH.
196
197       PATH    Determine the search  path  used  during  the  command  search,
198               except as described under the -p option.
199
200

EXIT STATUS

202   /usr/bin/command
203       When  the -v or -V options are specified, the following exit values are
204       returned:
205
206       0     Successful completion.
207
208
209       >0    The command_name could not be found or an error occurred.
210
211
212
213       Otherwise, the following exit values are returned:
214
215       126    The utility specified by command_name was found but could not be
216              invoked.
217
218
219       127    An  error  occurred in the command utility or the utility speci‐
220              fied by command_name could not be found.
221
222
223
224       Otherwise, the exit status of command is that  of  the  simple  command
225       specified by the arguments to command.
226
227   ksh93
228       If  command  is invoked, the exit status of command is that of command.
229       Otherwise, it is one of the following:
230
231       0      command_name completed successfully.
232
233
234       >0     -v or -V has been specified and an error occurred.
235
236
237       126    command_name was found but could not be invoked.
238
239
240       127    command_name could not be found.
241
242

ATTRIBUTES

244       See attributes(5) for descriptions of the following attributes:
245
246   /usr/bin/command
247       ┌─────────────────────────────┬─────────────────────────────┐
248       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
249       ├─────────────────────────────┼─────────────────────────────┤
250       │Availability                 │SUNWcsu                      │
251       ├─────────────────────────────┼─────────────────────────────┤
252       │Interface Stability          │Committed                    │
253       ├─────────────────────────────┼─────────────────────────────┤
254       │Standard                     │See standards(5).            │
255       └─────────────────────────────┴─────────────────────────────┘
256
257   ksh93
258       ┌─────────────────────────────┬─────────────────────────────┐
259       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
260       ├─────────────────────────────┼─────────────────────────────┤
261       │Availability                 │SUNWcsu                      │
262       ├─────────────────────────────┼─────────────────────────────┤
263       │Interface Stability          │Uncommitted                  │
264       └─────────────────────────────┴─────────────────────────────┘
265

SEE ALSO

267       ksh93(1), sh(1), type(1), whence(1), attributes(5),  environ(5),  stan‐
268       dards(5)
269
270
271
272SunOS 5.11                        8 Apr 2008                        command(1)
Impressum