6001 strcat(9f) needs a manpage
[unleashed.git] / usr / src / man / man1 / command.1
blob5f3e7112cd477d0e6f2973362d444d79f4981e55
1 '\" te
2 .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved
3 .\" Portions Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
4 .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
5 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
6 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
8 .\"  This notice shall appear on any product containing this material.
9 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
10 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
11 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
12 .TH COMMAND 1 "Apr 8, 2008"
13 .SH NAME
14 command \- execute a simple command
15 .SH SYNOPSIS
16 .SS "/usr/bin/command"
17 .LP
18 .nf
19 \fBcommand\fR [\fB-p\fR] \fIcommand_name\fR [\fIargument\fR]...
20 .fi
22 .LP
23 .nf
24 \fBcommand\fR [\fB-v\fR | \fB-V\fR] \fIcommand_name\fR
25 .fi
27 .SS "ksh93"
28 .LP
29 .nf
30 \fBcommand\fR [\fB-pvxV\fR] [\fIcommand_name\fR [\fIargument\fR...]]
31 .fi
33 .SH DESCRIPTION
34 .sp
35 .LP
36 The \fBcommand\fR utility causes the shell to treat the arguments as a simple
37 command, suppressing the shell function lookup.
38 .sp
39 .LP
40 If the \fIcommand_name\fR is the same as the name of one of the special
41 built-in utilities, the special properties do not occur. In every other
42 respect, if \fIcommand_name\fR is not the name of a function, the effect of
43 \fBcommand\fR (with no options) are the same as omitting \fBcommand\fR.
44 .sp
45 .LP
46 The \fBcommand\fR utility also provides information concerning how a command
47 name is interpreted by the shell. See \fB-v\fR and \fB-V\fR.
48 .SS "ksh93"
49 .sp
50 .LP
51 Without the \fB-v\fR or \fB-V\fR option, \fBcommand\fR executes
52 \fIcommand_name\fR with arguments specified by \fIargument\fR, suppressing the
53 shell function lookup that normally occurs. In addition, if \fIcommand\fR is a
54 special built-in command, the special properties are removed so that failures
55 do not cause the script that executes it to terminate.
56 .sp
57 .LP
58 If the \fB-v\fR or \fB-V\fR options are specified, \fBcommand\fR is equivalent
59 to \fBwhence\fR(1).
60 .SH OPTIONS
61 .sp
62 .LP
63 The following options are supported by \fB/usr/bin/command\fR:
64 .sp
65 .ne 2
66 .na
67 \fB\fB-p\fR\fR
68 .ad
69 .RS 6n
70 Performs the command search using a default value for \fBPATH\fR that is
71 guaranteed to find all of the standard utilities.
72 .RE
74 .sp
75 .ne 2
76 .na
77 \fB\fB-v\fR\fR
78 .ad
79 .RS 6n
80 Writes a string to standard output that indicates the path or command that is
81 be used by the shell, in the current shell execution environment to invoke
82 \fIcommand_name\fR, but does not invoke \fIcommand_name\fR.
83 .RS +4
84 .TP
85 .ie t \(bu
86 .el o
87 Utilities, regular built-in utilities, \fIcommand_names\fR including a slash
88 character, and any implementation-provided functions that are found using the
89 \fBPATH\fR variable is written as absolute path names.
90 .RE
91 .RS +4
92 .TP
93 .ie t \(bu
94 .el o
95 Shell functions, special built-in utilities, regular built-in utilities not
96 associated with a \fBPATH\fR search, and shell reserved words are written as
97 just their names.
98 .RE
99 .RS +4
101 .ie t \(bu
102 .el o
103 An alias is written as a command line that represents its alias definition.
105 .RS +4
107 .ie t \(bu
108 .el o
109 Otherwise, no output is written and the exit status reflects that the name was
110 not found.
115 .ne 2
117 \fB\fB-V\fR\fR
119 .RS 6n
120 Writes a string to standard output that indicates how the name specified in the
121 \fIcommand_name\fR operand is interpreted by the shell, in the current shell
122 execution environment, but does not invoke \fIcommand_name\fR. Although the
123 format of this string is unspecified, it indicates in which of the following
124 categories \fIcommand_name\fR falls and include the information stated:
125 .RS +4
127 .ie t \(bu
128 .el o
129 Utilities, regular built-in utilities, and any implementation-provided
130 functions that are found using the \fBPATH\fR variable is identified as such
131 and include the absolute path name in the string.
133 .RS +4
135 .ie t \(bu
136 .el o
137 Other shell functions is identified as functions.
139 .RS +4
141 .ie t \(bu
142 .el o
143 Aliases are identified as aliases and their definitions are included in the
144 string.
146 .RS +4
148 .ie t \(bu
149 .el o
150 Special built-in utilities are identified as special built-in utilities.
152 .RS +4
154 .ie t \(bu
155 .el o
156 Regular built-in utilities not associated with a \fBPATH\fR search is
157 identified as regular built-in utilities.
159 .RS +4
161 .ie t \(bu
162 .el o
163 Shell reserved words are identified as reserved words.
167 .SS "ksh93"
170 The following options are supported by \fBksh93\fR \fBcommand\fR:
172 .ne 2
174 \fB\fB-p\fR\fR
176 .RS 6n
177 Causes a default path to be searched rather than the one defined by the value
178 of \fBPATH\fR.
182 .ne 2
184 \fB\fB-v\fR\fR
186 .RS 6n
187 Equivalent to:
189 .in +2
191 whence \fIcommand\fR [\fIargument\fR ...]
193 .in -2
199 .ne 2
201 \fB\fB-V\fR\fR
203 .RS 6n
204 Equivalent to:
206 .in +2
208 whence -v \fIcommand\fR [\fIargument\fR ...]
210 .in -2
216 .ne 2
218 \fB\fB-x\fR\fR
220 .RS 6n
221 If command fails because there are too many arguments, it is invoked multiple
222 times with a subset of the arguments on each invocation. Arguments that occur
223 prior to the first word that expand to multiple arguments and arguments that
224 occur after the last word that expands to multiple arguments are passed on each
225 invocation. The exit status is the maximum invocation exit status.
228 .SH OPERANDS
231 The following operands are supported:
233 .ne 2
235 \fB\fIargument\fR\fR
237 .RS 16n
238 One of the strings treated as an argument to \fIcommand_name\fR.
242 .ne 2
244 \fB\fIcommand_name\fR\fR
246 .RS 16n
247 The name of a utility or a special built-in utility.
250 .SH EXAMPLES
252 \fBExample 1 \fRMaking a Version of \fBcd\fR That Always Prints Out the New
253 Working Directory
256 The following example takes a version of \fBcd\fR that always prints out the
257 new working directory exactly once:
260 .in +2
262 cd() {
263         command cd "$@" >/dev/null
264         pwd
267 .in -2
271 \fBExample 2 \fRStarting Off a \fBsecure shell script\fR in Which the Script
272 Avoids Being Spoofed by Its Parent
275 The following example starts off a \fBsecure shell script\fR in which the
276 script avoids being spoofed by its parent:
279 .in +2
281 IFS='
283 #       The preceding value should be <space><tab><newline>.
284 #       Set IFS to its default value.
285 \eunalias -a
286 #       Unset all possible aliases.
287 #       Note that unalias is escaped to prevent an alias
288 #       being used for unalias.
289 unset -f command
290 #       Ensure command is not a user function.
291 PATH="$(command -p getconf _CS_PATH):$PATH"
292 #       Put on a reliable PATH prefix.
293 #       ...
295 .in -2
300 At this point, given correct permissions on the directories called by
301 \fBPATH\fR, the script has the ability to ensure that any utility it calls is
302 the intended one. It is being very cautious because it assumes that
303 implementation extensions can be present that would allow user functions to
304 exist when it is invoked. This capability is not specified by this document,
305 but it is not prohibited as an extension. For example, the \fBENV\fR variable
306 precedes the invocation of the script with a user startup script. Such a script
307 could define functions to spoof the application.
309 .SH ENVIRONMENT VARIABLES
312 See \fBenviron\fR(5) for descriptions of the following environment variables
313 that affect the execution of \fBcommand\fR: \fBLANG\fR, \fBLC_ALL\fR,
314 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
316 .ne 2
318 \fB\fBPATH\fR\fR
320 .RS 8n
321 Determine the search path used during the command search, except as described
322 under the \fB-p\fR option.
325 .SH EXIT STATUS
326 .SS "/usr/bin/command"
329 When the \fB-v\fR or \fB-V\fR options are specified, the following exit values
330 are returned:
332 .ne 2
334 \fB\fB0\fR\fR
336 .RS 6n
337 Successful completion.
341 .ne 2
343 \fB\fB>0\fR\fR
345 .RS 6n
346 The \fIcommand_name\fR could not be found or an error occurred.
351 Otherwise, the following exit values are returned:
353 .ne 2
355 \fB\fB126\fR\fR
357 .RS 7n
358 The utility specified by \fIcommand_name\fR was found but could not be invoked.
362 .ne 2
364 \fB\fB127\fR\fR
366 .RS 7n
367 An error occurred in the \fBcommand\fR utility or the utility specified by
368 \fIcommand_name\fR could not be found.
373 Otherwise, the exit status of \fBcommand\fR is that of the simple command
374 specified by the arguments to \fBcommand\fR.
375 .SS "ksh93"
378 If \fIcommand\fR is invoked, the exit status of \fBcommand\fR is that of
379 \fIcommand\fR. Otherwise, it is one of the following:
381 .ne 2
383 \fB\fB0\fR\fR
385 .RS 7n
386 \fIcommand_name\fR completed successfully.
390 .ne 2
392 \fB\fB>0\fR\fR
394 .RS 7n
395 \fB-v\fR or \fB-V\fR has been specified and an error occurred.
399 .ne 2
401 \fB\fB126\fR\fR
403 .RS 7n
404 \fIcommand_name\fR was found but could not be invoked.
408 .ne 2
410 \fB\fB127\fR\fR
412 .RS 7n
413 \fIcommand_name\fR could not be found.
416 .SH ATTRIBUTES
419 See \fBattributes\fR(5) for descriptions of the following attributes:
420 .SS "/usr/bin/command"
425 box;
426 c | c
427 l | l .
428 ATTRIBUTE TYPE  ATTRIBUTE VALUE
430 Interface Stability     Committed
432 Standard        See \fBstandards\fR(5).
435 .SS "ksh93"
440 box;
441 c | c
442 l | l .
443 ATTRIBUTE TYPE  ATTRIBUTE VALUE
445 Interface Stability     Uncommitted
448 .SH SEE ALSO
451 \fBksh93\fR(1), \fBsh\fR(1), \fBtype\fR(1), \fBwhence\fR(1),
452 \fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)