'\" te .\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved. .\" Copyright 1989 AT&T .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures .\" 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. .\" 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. .\" 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] .TH shell_builtins 1 "20 Nov 2007" "SunOS 5.11" "User Commands" .SH NAME shell_builtins, case, for, foreach, function, if, repeat, select, switch, until, while \- shell command interpreter built-in commands .SH DESCRIPTION .sp .LP The shell command interpreters \fBcsh\fR(1), \fBksh\fR(1), \fBksh93\fR(1), and \fBsh\fR(1) have special built-in commands. The commands \fBcase\fR, \fBfor\fR, \fBforeach\fR, \fBfunction\fR, \fBif\fR, \fBrepeat\fR, \fBselect\fR, \fBswitch\fR, \fBuntil\fR, and \fBwhile\fR are commands in the syntax recognized by the shells. They are described in the \fBCommands\fR section of the manual pages of the respective shells. In \fBksh93\fR(1), \fBfc\fR, \fBhash\fR, \fBstop\fR, \fBsuspend\fR, \fBtimes\fR, and \fBtype\fR are aliases by default. In \fBksh93\fR, the following built-ins are bound to the \fB/bin\fR pathname by default and are invoked if the pathname search encounters an executable command of that name in the \fB/bin\fR or \fB/usr/bin\fR directory: \fBcat\fR, \fBchown\fR, \fBgetconf\fR, \fBhead\fR, \fBmkdir\fR, \fBrmdir\fR, \fBtee\fR, \fBuniq\fR, and \fBwc\fR. .sp .LP The remaining commands listed in the following table are built into the shells for reasons such as efficiency or data sharing between command invocations. They are described on their respective manual pages. .sp .sp .TS tab(); cw(2.75i) cw(2.75i) lw(2.75i) lw(2.75i) . CommandShell _ \fB++**alias\fRcsh, ksh, ksh93 \fBbg\fRcsh, ksh, ksh93, sh \fB+*break\fRcsh, ksh, ksh93, sh \fBbuiltin\fRksh93 \fBcase\fRcsh, ksh, ksh93, sh \fBcat\fRksh93 \fBcd\fRcsh, ksh, ksh93, sh \fBchdir\fRcsh, sh \fBchown\fRksh93 \fBcommand\fRksh93 \fB+*continue\fRcsh, ksh, ksh93, sh \fBdirs\fRcsh \fBdisown\fRksh93 \fBecho\fRcsh, ksh, ksh93, sh \fB+*eval\fRcsh, ksh, ksh93, sh \fB+*exec\fRcsh, ksh, ksh93, sh \fB+*exit\fRcsh, ksh, ksh93, sh \fB++**export\fRksh, ksh93, sh \fBfalse\fRksh, ksh93 \fBfc\fRksh, ksh93 \fBfg\fRcsh, ksh, ksh93, sh \fBfor\fRksh, ksh93, sh \fBforeach\fRcsh \fBfunction\fRksh, ksh93 \fBgetconf\fRksh93 \fBgetopts\fRksh, ksh93, sh \fBglob\fRcsh \fBgoto\fRcsh \fBhash\fRksh, ksh93, sh \fBhashstat\fRcsh \fBhead\fRksh93 \fBhist\fRksh93 \fBhistory\fRcsh \fBif\fRcsh, ksh, ksh93, sh \fBjobs\fRcsh, ksh, ksh93, sh \fBkill\fRcsh, ksh, ksh93, sh \fBlet\fRksh, ksh93, \fBlimit\fRcsh \fBlogin\fRcsh, ksh, ksh93, sh \fBlogout\fRcsh \fBmkdir\fRksh93 \fBnice\fRcsh \fB+*newgrp\fRksh, ksh93, sh \fBnohup\fRcsh \fBnotify\fRcsh \fBonintr\fRcsh \fBpopd\fRcsh \fBprint\fRksh, ksh93 \fBprintf\fRksh93 \fBpushd\fRcsh \fBpwd\fRksh, ksh93, sh \fBread\fRksh, ksh93, sh \fB++**readonly\fRksh, ksh93, sh \fBrehash\fRcsh \fBrepeat\fRcsh \fB+*return\fRksh, ksh93, sh \fBselect\fRksh, ksh93 \fB+set\fRcsh, ksh, ksh93, sh \fBsetenv\fRcsh \fBshift\fRcsh, ksh, ksh93, sh \fBsleep\fRksh93 \fBsource\fRcsh \fBstop\fRcsh, ksh, ksh93, sh \fBsuspend\fRcsh, ksh, sh \fBswitch\fRcsh \fBtee\fRksh93 \fBtest\fRksh, ksh93, sh \fBtime\fRcsh \fB*times\fRksh, ksh93, sh \fB*+trap\fRksh, ksh93, sh \fBtrue\fRksh, ksh93 \fBtype\fRksh, ksh93, sh \fB++**typeset\fRksh, ksh93 \fBulimit\fRksh, ksh93, sh \fBumask\fRcsh, ksh, ksh93, sh \fB+unalias\fRcsh, ksh, ksh93 \fBunhash\fRcsh \fBuniq\fRksh93 \fBunlimit\fRcsh \fB+unset\fRcsh, ksh, ksh93, sh \fBunsetenv\fRcsh \fBuntil\fRksh, ksh93, sh \fB*wait\fRcsh, ksh, ksh93, sh \fBwhence\fRksh, ksh93 \fBwhile\fRcsh, ksh, ksh93, sh .TE .SS "Bourne Shell, sh, Special Commands" .sp .LP Input/output redirection is now permitted for these commands. File descriptor 1 is the default output location. When Job Control is enabled, additional \fBSpecial Commands\fR are added to the shell's environment. .sp .LP In addition to these built-in reserved command words, \fBsh\fR also uses: .sp .ne 2 .mk .na \fB\fB:\fR\fR .ad .RS 15n .rt No effect; the command does nothing. A zero exit code is returned. .RE .sp .ne 2 .mk .na \fB\fB\&.\fR\fIfilename\fR\fR .ad .RS 15n .rt Read and execute commands from \fIfilename\fR and return. The search path specified by \fBPATH\fR is used to find the directory containing \fIfilename\fR. .RE .SS "C shell, csh" .sp .LP Built-in commands are executed within the C shell. If a built-in command occurs as any component of a pipeline except the last, it is executed in a subshell. In addition to these built-in reserved command words, \fBcsh\fR also uses: .sp .ne 2 .mk .na \fB\fB:\fR\fR .ad .RS 5n .rt Null command. This command is interpreted, but performs no action. .RE .SS "Korn Shell, ksh, Special Commands" .sp .LP Input/Output redirection is permitted. Unless otherwise indicated, the output is written on file descriptor 1 and the exit status, when there is no syntax error, is zero. .sp .LP Commands that are preceded by one or two \fB*\fR (asterisks) are treated specially in the following ways: .RS +4 .TP 1. Variable assignment lists preceding the command remain in effect when the command completes. .RE .RS +4 .TP 2. \fBI/O\fR redirections are processed after variable assignments. .RE .RS +4 .TP 3. Errors cause a script that contains them to abort. .RE .RS +4 .TP 4. Words, following a command preceded by \fB**\fR that are in the format of a variable assignment, are expanded with the same rules as a variable assignment. This means that tilde substitution is performed after the \fB=\fR sign and word splitting and file name generation are not performed. .RE .sp .LP In addition to these built-in reserved command words, \fBksh\fR also uses: .sp .ne 2 .mk .na \fB* \fB:\fR [ \fIarg\fR .\|.\|. ]\fR .ad .RS 29n .rt The command only expands parameters. .RE .sp .ne 2 .mk .na \fB* \fB\&.\fR\fIfile\fR [ \fIarg\fR .\|.\|. ]\fR .ad .RS 29n .rt Read the complete \fIfile\fR then execute the commands. The commands are executed in the current shell environment. The search path specified by \fBPATH\fR is used to find the directory containing \fIfile\fR. If any arguments \fIarg\fR are specified, they become the positional parameters. Otherwise, the positional parameters are unchanged. The exit status is the exit status of the last command executed. the loop termination test. .RE .SS "Korn Shell, ksh93, Special Commands" .sp .LP Input/Output redirection is permitted. Unless otherwise indicated, the output is written on file descriptor 1 and the exit status, when there is no syntax error, is zero. .sp .LP Except for \fB:\fR, \fBtrue\fR, \fBfalse\fR, \fBecho\fR, \fBnewgrp\fR, and \fBlogin\fR, all built-in commands accept \fB--\fR to indicate end of options. They also interpret the option \fB--man\fR as a request to display the manual page onto standard error and \fB-?\fR as a help request which prints a usage message on standard error. .sp .LP Commands that are preceded by one or two \fB+\fR are treated specially in the following ways: .RS +4 .TP 1. Variable assignment lists preceding the command remain in effect when the command completes. .RE .RS +4 .TP 2. \fBI/O\fR redirections are processed after variable assignments. .RE .RS +4 .TP 3. Errors cause a script that contains them to abort. .RE .RS +4 .TP 4. They are not valid function names. .RE .RS +4 .TP 5. Words, following a command preceded by \fB++\fR that are in the format of a variable assignment, are expanded with the same rules as a variable assignment. This means that tilde substitution is performed after the \fB=\fR sign and field splitting and file name generation are not performed. .RE .sp .LP In addition to these built-in reserved command words, \fBksh93\fR also uses: .sp .ne 2 .mk .na \fB\fB:\fR [ \fIarg\fR .\|.\|. ]\fR .ad .RS 27n .rt The command only expands parameters. .RE .sp .ne 2 .mk .na \fB\fB\&.\fR\fIname\fR [ \fIarg\fR .\|.\|. ]\fR .ad .RS 27n .rt If \fIname\fR is a function defined with the function \fIname\fR reserved word syntax, the function is executed in the current environment (as if it had been defined with the \fBname()\fR syntax.) Otherwise if \fIname\fR refers to a file, the file is read in its entirety and the commands are executed in the current shell environment. The search path specified by \fBPATH\fR is used to find the directory containing the file. If any arguments \fIarg\fR are specified, they become the positional parameters while processing the \fB\&.\fR command and the original positional parameters are restored upon completion. Otherwise the positional parameters are unchanged. The exit status is the exit status of the last command executed. .RE .SH SEE ALSO .sp .LP \fBIntro\fR(1), \fBalias\fR(1), \fBbreak\fR(1), \fBbuiltin\fR(1), \fBcd\fR(1), \fBchmod\fR(1), \fBcsh\fR(1), \fBdisown\fR(1), \fBecho\fR(1), \fBexec\fR(1), \fBexit\fR(1), \fBfind\fR(1), \fBgetoptcvt\fR(1), \fBgetopts\fR(1), \fBglob\fR(1), \fBhash\fR(1), \fBhistory\fR(1), \fBjobs\fR(1), \fBkill\fR(1), \fBksh\fR(1), \fBksh93\fR(1), \fBlet\fR(1), \fBlimit\fR(1), \fBlogin\fR(1), \fBlogout\fR(1), \fBnewgrp\fR(1), \fBnice\fR(1), \fBnohup\fR(1), \fBprint\fR(1), \fBprintf\fR(1), \fBpwd\fR(1), \fBread\fR(1), \fBreadonly\fR(1), \fBset\fR(1), \fBsh\fR(1), \fBshift\fR(1), \fBsleep\fR(1), \fBsuspend\fR(1), \fBtest\fR(1)\fBtest\fR(1), \fBtest\fR(1B), \fBtime\fR(1), \fBtimes\fR(1), \fBtrap\fR(1), \fBtypeset\fR(1), \fBumask\fR(1), \fBwait\fR(1), \fBchdir\fR(2), \fBchmod\fR(2), \fBcreat\fR(2), \fBumask\fR(2), \fBgetopt\fR(3C), \fBprofile\fR(4), \fBenviron\fR(5)