Move everything from /var/adm to /var/log
[unleashed.git] / share / man / man1 / shell_builtins.1
bloba5121797a71b4d05b697301a7e62e46ba8ab99ff
1 '\" te
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"
9 .SH NAME
10 shell_builtins, case, for, foreach, function, if, repeat, select, switch,
11 until, while \- shell command interpreter built-in commands
12 .SH DESCRIPTION
13 .sp
14 .LP
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.
27 .sp
28 .LP
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.
32 .sp
34 .sp
35 .TS
36 c c
37 l l .
38 Command Shell
40 \fB++**alias\fR csh, ksh, ksh93
41 \fBbg\fR        csh, ksh, ksh93, sh
42 \fB+*break\fR   csh, ksh, ksh93, sh
43 \fBbuiltin\fR   ksh93
44 \fBcase\fR      csh, ksh, ksh93, sh
45 \fBcat\fR       ksh93
46 \fBcd\fR        csh, ksh, ksh93, sh
47 \fBchdir\fR     csh, sh
48 \fBchown\fR     ksh93
49 \fBcommand\fR   ksh93
50 \fB+*continue\fR        csh, ksh, ksh93, sh
51 \fBdirs\fR      csh
52 \fBdisown\fR    ksh93
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
59 \fBfc\fR        ksh, ksh93
60 \fBfg\fR        csh, ksh, ksh93, sh
61 \fBfor\fR       ksh, ksh93, sh
62 \fBforeach\fR   csh
63 \fBfunction\fR  ksh, ksh93
64 \fBgetconf\fR   ksh93
65 \fBgetopts\fR   ksh, ksh93, sh
66 \fBglob\fR      csh
67 \fBgoto\fR      csh
68 \fBhash\fR      ksh, ksh93, sh
69 \fBhashstat\fR  csh
70 \fBhead\fR      ksh93
71 \fBhist\fR      ksh93
72 \fBhistory\fR   csh
73 \fBif\fR        csh, ksh, ksh93, sh
74 \fBjobs\fR      csh, ksh, ksh93, sh
75 \fBkill\fR      csh, ksh, ksh93, sh
76 \fBlet\fR       ksh, ksh93,
77 \fBlimit\fR     csh
78 \fBlogin\fR     csh, ksh, ksh93, sh
79 \fBlogout\fR    csh
80 \fBmkdir\fR     ksh93
81 \fBnice\fR      csh
82 \fB+*newgrp\fR  ksh, ksh93, sh
83 \fBnohup\fR     csh
84 \fBnotify\fR    csh
85 \fBonintr\fR    csh
86 \fBpopd\fR      csh
87 \fBprint\fR     ksh, ksh93
88 \fBprintf\fR    ksh93
89 \fBpushd\fR     csh
90 \fBpwd\fR       ksh, ksh93, sh
91 \fBread\fR      ksh, ksh93, sh
92 \fB++**readonly\fR      ksh, ksh93, sh
93 \fBrehash\fR    csh
94 \fBrepeat\fR    csh
95 \fB+*return\fR  ksh, ksh93, sh
96 \fBselect\fR    ksh, ksh93
97 \fB+set\fR      csh, ksh, ksh93, sh
98 \fBsetenv\fR    csh
99 \fBshift\fR     csh, ksh, ksh93, sh
100 \fBsleep\fR     ksh93
101 \fBsource\fR    csh
102 \fBstop\fR      csh, ksh, ksh93, sh
103 \fBsuspend\fR   csh, ksh, sh
104 \fBswitch\fR    csh
105 \fBtee\fR       ksh93
106 \fBtest\fR      ksh, ksh93, sh
107 \fBtime\fR      csh
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
116 \fBunhash\fR    csh
117 \fBuniq\fR      ksh93
118 \fBunlimit\fR   csh
119 \fB+unset\fR    csh, ksh, ksh93, sh
120 \fBunsetenv\fR  csh
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:
137 .ne 2
139 \fB\fB:\fR\fR
141 .RS 15n
142 No effect; the command does nothing. A zero exit code is returned.
146 .ne 2
148 \fB\fB\&.\fR\fIfilename\fR\fR
150 .RS 15n
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
153 \fIfilename\fR.
156 .SS "C shell, csh"
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:
163 .ne 2
165 \fB\fB:\fR\fR
167 .RS 5n
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
176 error, is zero.
179 Commands that are preceded by one or two \fB*\fR (asterisks) are treated
180 specially in the following ways:
181 .RS +4
184 Variable assignment lists preceding the command remain in effect when the
185 command completes.
187 .RS +4
190 \fBI/O\fR redirections are processed after variable assignments.
192 .RS +4
195 Errors cause a script that contains them to abort.
197 .RS +4
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:
209 .ne 2
211 \fB* \fB:\fR [ \fIarg\fR .\|.\|. ]\fR
213 .RS 29n
214 The command only expands parameters.
218 .ne 2
220 \fB* \fB\&.\fR\fIfile\fR [ \fIarg\fR .\|.\|. ]\fR
222 .RS 29n
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
236 error, is zero.
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
247 following ways:
248 .RS +4
251 Variable assignment lists preceding the command remain in effect when the
252 command completes.
254 .RS +4
257 \fBI/O\fR redirections are processed after variable assignments.
259 .RS +4
262 Errors cause a script that contains them to abort.
264 .RS +4
267 They are not valid function names.
269 .RS +4
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:
281 .ne 2
283 \fB\fB:\fR [ \fIarg\fR .\|.\|. ]\fR
285 .RS 27n
286 The command only expands parameters.
290 .ne 2
292 \fB\fB\&.\fR\fIname\fR [ \fIarg\fR .\|.\|. ]\fR
294 .RS 27n
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.
307 .SH SEE ALSO
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)