2 .\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright 1989 AT&T
4 .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
5 .\" 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.
6 .\" 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.
7 .\" 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]
8 .TH SHELL_BUILTINS 1 "Nov 20, 2007"
10 shell_builtins, case, for, foreach, function, if, repeat, select, switch,
11 until, while \- shell command interpreter built-in commands
15 The shell command interpreters \fBcsh\fR(1), \fBksh\fR(1), \fBksh93\fR(1), and
16 \fBsh\fR(1) have special built-in commands. The commands \fBcase\fR, \fBfor\fR,
17 \fBforeach\fR, \fBfunction\fR, \fBif\fR, \fBrepeat\fR, \fBselect\fR,
18 \fBswitch\fR, \fBuntil\fR, and \fBwhile\fR are commands in the syntax
19 recognized by the shells. They are described in the \fBCommands\fR section of
20 the manual pages of the respective shells. In \fBksh93\fR(1), \fBfc\fR,
21 \fBhash\fR, \fBstop\fR, \fBsuspend\fR, \fBtimes\fR, and \fBtype\fR are aliases
22 by default. In \fBksh93\fR, the following built-ins are bound to the \fB/bin\fR
23 pathname by default and are invoked if the pathname search encounters an
24 executable command of that name in the \fB/bin\fR or \fB/usr/bin\fR directory:
25 \fBcat\fR, \fBchown\fR, \fBgetconf\fR, \fBhead\fR, \fBmkdir\fR, \fBrmdir\fR,
26 \fBtee\fR, \fBuniq\fR, and \fBwc\fR.
29 The remaining commands listed in the following table are built into the shells
30 for reasons such as efficiency or data sharing between command invocations.
31 They are described on their respective manual pages.
40 \fB++**alias\fR csh, ksh, ksh93
41 \fBbg\fR csh, ksh, ksh93, sh
42 \fB+*break\fR csh, ksh, ksh93, sh
44 \fBcase\fR csh, ksh, ksh93, sh
46 \fBcd\fR csh, ksh, ksh93, sh
50 \fB+*continue\fR csh, ksh, ksh93, sh
53 \fBecho\fR csh, ksh, ksh93, sh
54 \fB+*eval\fR csh, ksh, ksh93, sh
55 \fB+*exec\fR csh, ksh, ksh93, sh
56 \fB+*exit\fR csh, ksh, ksh93, sh
57 \fB++**export\fR ksh, ksh93, sh
58 \fBfalse\fR ksh, ksh93
60 \fBfg\fR csh, ksh, ksh93, sh
61 \fBfor\fR ksh, ksh93, sh
63 \fBfunction\fR ksh, ksh93
65 \fBgetopts\fR ksh, ksh93, sh
68 \fBhash\fR ksh, ksh93, sh
73 \fBif\fR csh, ksh, ksh93, sh
74 \fBjobs\fR csh, ksh, ksh93, sh
75 \fBkill\fR csh, ksh, ksh93, sh
78 \fBlogin\fR csh, ksh, ksh93, sh
82 \fB+*newgrp\fR ksh, ksh93, sh
87 \fBprint\fR ksh, ksh93
90 \fBpwd\fR ksh, ksh93, sh
91 \fBread\fR ksh, ksh93, sh
92 \fB++**readonly\fR ksh, ksh93, sh
95 \fB+*return\fR ksh, ksh93, sh
96 \fBselect\fR ksh, ksh93
97 \fB+set\fR csh, ksh, ksh93, sh
99 \fBshift\fR csh, ksh, ksh93, sh
102 \fBstop\fR csh, ksh, ksh93, sh
103 \fBsuspend\fR csh, ksh, sh
106 \fBtest\fR ksh, ksh93, sh
108 \fB*times\fR ksh, ksh93, sh
109 \fB*+trap\fR ksh, ksh93, sh
110 \fBtrue\fR ksh, ksh93
111 \fBtype\fR ksh, ksh93, sh
112 \fB++**typeset\fR ksh, ksh93
113 \fBulimit\fR ksh, ksh93, sh
114 \fBumask\fR csh, ksh, ksh93, sh
115 \fB+unalias\fR csh, ksh, ksh93
119 \fB+unset\fR csh, ksh, ksh93, sh
121 \fBuntil\fR ksh, ksh93, sh
122 \fB*wait\fR csh, ksh, ksh93, sh
123 \fBwhence\fR ksh, ksh93
124 \fBwhile\fR csh, ksh, ksh93, sh
127 .SS "Bourne Shell, sh, Special Commands"
130 Input/output redirection is now permitted for these commands. File descriptor 1
131 is the default output location. When Job Control is enabled, additional
132 \fBSpecial Commands\fR are added to the shell's environment.
135 In addition to these built-in reserved command words, \fBsh\fR also uses:
142 No effect; the command does nothing. A zero exit code is returned.
148 \fB\fB\&.\fR\fIfilename\fR\fR
151 Read and execute commands from \fIfilename\fR and return. The search path
152 specified by \fBPATH\fR is used to find the directory containing
159 Built-in commands are executed within the C shell. If a built-in command occurs
160 as any component of a pipeline except the last, it is executed in a subshell.
161 In addition to these built-in reserved command words, \fBcsh\fR also uses:
168 Null command. This command is interpreted, but performs no action.
171 .SS "Korn Shell, ksh, Special Commands"
174 Input/Output redirection is permitted. Unless otherwise indicated, the output
175 is written on file descriptor 1 and the exit status, when there is no syntax
179 Commands that are preceded by one or two \fB*\fR (asterisks) are treated
180 specially in the following ways:
184 Variable assignment lists preceding the command remain in effect when the
190 \fBI/O\fR redirections are processed after variable assignments.
195 Errors cause a script that contains them to abort.
200 Words, following a command preceded by \fB**\fR that are in the format of a
201 variable assignment, are expanded with the same rules as a variable assignment.
202 This means that tilde substitution is performed after the \fB=\fR sign and word
203 splitting and file name generation are not performed.
207 In addition to these built-in reserved command words, \fBksh\fR also uses:
211 \fB* \fB:\fR [ \fIarg\fR .\|.\|. ]\fR
214 The command only expands parameters.
220 \fB* \fB\&.\fR\fIfile\fR [ \fIarg\fR .\|.\|. ]\fR
223 Read the complete \fIfile\fR then execute the commands. The commands are
224 executed in the current shell environment. The search path specified by
225 \fBPATH\fR is used to find the directory containing \fIfile\fR. If any
226 arguments \fIarg\fR are specified, they become the positional parameters.
227 Otherwise, the positional parameters are unchanged. The exit status is the exit
228 status of the last command executed. the loop termination test.
231 .SS "Korn Shell, ksh93, Special Commands"
234 Input/Output redirection is permitted. Unless otherwise indicated, the output
235 is written on file descriptor 1 and the exit status, when there is no syntax
239 Except for \fB:\fR, \fBtrue\fR, \fBfalse\fR, \fBecho\fR, \fBnewgrp\fR, and
240 \fBlogin\fR, all built-in commands accept \fB--\fR to indicate end of options.
241 They also interpret the option \fB--man\fR as a request to display the manual
242 page onto standard error and \fB-?\fR as a help request which prints a usage
243 message on standard error.
246 Commands that are preceded by one or two \fB+\fR are treated specially in the
251 Variable assignment lists preceding the command remain in effect when the
257 \fBI/O\fR redirections are processed after variable assignments.
262 Errors cause a script that contains them to abort.
267 They are not valid function names.
272 Words, following a command preceded by \fB++\fR that are in the format of a
273 variable assignment, are expanded with the same rules as a variable assignment.
274 This means that tilde substitution is performed after the \fB=\fR sign and
275 field splitting and file name generation are not performed.
279 In addition to these built-in reserved command words, \fBksh93\fR also uses:
283 \fB\fB:\fR [ \fIarg\fR .\|.\|. ]\fR
286 The command only expands parameters.
292 \fB\fB\&.\fR\fIname\fR [ \fIarg\fR .\|.\|. ]\fR
295 If \fIname\fR is a function defined with the function \fIname\fR reserved word
296 syntax, the function is executed in the current environment (as if it had been
297 defined with the \fBname()\fR syntax.) Otherwise if \fIname\fR refers to a
298 file, the file is read in its entirety and the commands are executed in the
299 current shell environment. The search path specified by \fBPATH\fR is used to
300 find the directory containing the file. If any arguments \fIarg\fR are
301 specified, they become the positional parameters while processing the \fB\&.\fR
302 command and the original positional parameters are restored upon completion.
303 Otherwise the positional parameters are unchanged. The exit status is the exit
304 status of the last command executed.
310 \fBIntro\fR(1), \fBalias\fR(1), \fBbreak\fR(1), \fBbuiltin\fR(1), \fBcd\fR(1),
311 \fBchmod\fR(1), \fBcsh\fR(1), \fBdisown\fR(1), \fBecho\fR(1), \fBexec\fR(1),
312 \fBexit\fR(1), \fBfind\fR(1), \fBgetoptcvt\fR(1), \fBgetopts\fR(1),
313 \fBglob\fR(1), \fBhash\fR(1), \fBhistory\fR(1), \fBjobs\fR(1), \fBkill\fR(1),
314 \fBksh\fR(1), \fBksh93\fR(1), \fBlet\fR(1), \fBlimit\fR(1), \fBlogin\fR(1),
315 \fBlogout\fR(1), \fBnewgrp\fR(1), \fBnice\fR(1), \fBnohup\fR(1),
316 \fBprint\fR(1), \fBprintf\fR(1), \fBpwd\fR(1), \fBread\fR(1),
317 \fBreadonly\fR(1), \fBset\fR(1), \fBsh\fR(1), \fBshift\fR(1), \fBsleep\fR(1),
318 \fBsuspend\fR(1), \fBtest\fR(1), \fBtest\fR(1B), \fBtime\fR(1),
319 \fBtimes\fR(1), \fBtrap\fR(1), \fBtypeset\fR(1), \fBumask\fR(1), \fBwait\fR(1),
320 \fBchdir\fR(2), \fBchmod\fR(2), \fBcreat\fR(2), \fBumask\fR(2),
321 \fBgetopt\fR(3C), \fBprofile\fR(4), \fBenviron\fR(5)