'\" 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 "Nov 20, 2007" .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 c c l l . Command Shell _ \fB++**alias\fR csh, ksh, ksh93 \fBbg\fR csh, ksh, ksh93, sh \fB+*break\fR csh, ksh, ksh93, sh \fBbuiltin\fR ksh93 \fBcase\fR csh, ksh, ksh93, sh \fBcat\fR ksh93 \fBcd\fR csh, ksh, ksh93, sh \fBchdir\fR csh, sh \fBchown\fR ksh93 \fBcommand\fR ksh93 \fB+*continue\fR csh, ksh, ksh93, sh \fBdirs\fR csh \fBdisown\fR ksh93 \fBecho\fR csh, ksh, ksh93, sh \fB+*eval\fR csh, ksh, ksh93, sh \fB+*exec\fR csh, ksh, ksh93, sh \fB+*exit\fR csh, ksh, ksh93, sh \fB++**export\fR ksh, ksh93, sh \fBfalse\fR ksh, ksh93 \fBfc\fR ksh, ksh93 \fBfg\fR csh, ksh, ksh93, sh \fBfor\fR ksh, ksh93, sh \fBforeach\fR csh \fBfunction\fR ksh, ksh93 \fBgetconf\fR ksh93 \fBgetopts\fR ksh, ksh93, sh \fBglob\fR csh \fBgoto\fR csh \fBhash\fR ksh, ksh93, sh \fBhashstat\fR csh \fBhead\fR ksh93 \fBhist\fR ksh93 \fBhistory\fR csh \fBif\fR csh, ksh, ksh93, sh \fBjobs\fR csh, ksh, ksh93, sh \fBkill\fR csh, ksh, ksh93, sh \fBlet\fR ksh, ksh93, \fBlimit\fR csh \fBlogin\fR csh, ksh, ksh93, sh \fBlogout\fR csh \fBmkdir\fR ksh93 \fBnice\fR csh \fB+*newgrp\fR ksh, ksh93, sh \fBnohup\fR csh \fBnotify\fR csh \fBonintr\fR csh \fBpopd\fR csh \fBprint\fR ksh, ksh93 \fBprintf\fR ksh93 \fBpushd\fR csh \fBpwd\fR ksh, ksh93, sh \fBread\fR ksh, ksh93, sh \fB++**readonly\fR ksh, ksh93, sh \fBrehash\fR csh \fBrepeat\fR csh \fB+*return\fR ksh, ksh93, sh \fBselect\fR ksh, ksh93 \fB+set\fR csh, ksh, ksh93, sh \fBsetenv\fR csh \fBshift\fR csh, ksh, ksh93, sh \fBsleep\fR ksh93 \fBsource\fR csh \fBstop\fR csh, ksh, ksh93, sh \fBsuspend\fR csh, ksh, sh \fBswitch\fR csh \fBtee\fR ksh93 \fBtest\fR ksh, ksh93, sh \fBtime\fR csh \fB*times\fR ksh, ksh93, sh \fB*+trap\fR ksh, ksh93, sh \fBtrue\fR ksh, ksh93 \fBtype\fR ksh, ksh93, sh \fB++**typeset\fR ksh, ksh93 \fBulimit\fR ksh, ksh93, sh \fBumask\fR csh, ksh, ksh93, sh \fB+unalias\fR csh, ksh, ksh93 \fBunhash\fR csh \fBuniq\fR ksh93 \fBunlimit\fR csh \fB+unset\fR csh, ksh, ksh93, sh \fBunsetenv\fR csh \fBuntil\fR ksh, ksh93, sh \fB*wait\fR csh, ksh, ksh93, sh \fBwhence\fR ksh, ksh93 \fBwhile\fR csh, 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 .na \fB\fB:\fR\fR .ad .RS 15n No effect; the command does nothing. A zero exit code is returned. .RE .sp .ne 2 .na \fB\fB\&.\fR\fIfilename\fR\fR .ad .RS 15n 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 .na \fB\fB:\fR\fR .ad .RS 5n 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 .na \fB* \fB:\fR [ \fIarg\fR .\|.\|. ]\fR .ad .RS 29n The command only expands parameters. .RE .sp .ne 2 .na \fB* \fB\&.\fR\fIfile\fR [ \fIarg\fR .\|.\|. ]\fR .ad .RS 29n 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 .na \fB\fB:\fR [ \fIarg\fR .\|.\|. ]\fR .ad .RS 27n The command only expands parameters. .RE .sp .ne 2 .na \fB\fB\&.\fR\fIname\fR [ \fIarg\fR .\|.\|. ]\fR .ad .RS 27n 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(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)