2 .\" Copyright 1989 AT&T
3 .\" Copyright (c) 2007 Sun Microsystems, Inc. - All Rights Reserved.
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 EXIT 1 "Nov 2, 2007"
10 exit, return, goto \- shell built-in functions to enable the execution of the
11 shell to advance beyond its sequence of steps
21 \fBreturn\fR [\fIn\fR]
27 \fBexit\fR [( \fIexpr\fR )]
32 \fBgoto\fR \fIlabel\fR
43 \fB*return\fR [\fIn\fR]
54 \fB+return\fR [\fIn\fR]
61 \fBexit\fR causes the calling shell or shell script to exit with the exit
62 status specified by \fIn\fR. If \fIn\fR is omitted the exit status is that of
63 the last command executed (an \fBEOF\fR also causes the shell to exit.)
66 \fBreturn\fR causes a function to exit with the return value specified by
67 \fIn\fR. If \fIn\fR is omitted, the return status is that of the last command
72 \fBexit\fR causes the calling shell or shell script to exit, either with the
73 value of the status variable or with the value specified by the expression
77 The \fBgoto\fR built-in uses a specified \fIlabel\fR as a search string amongst
78 commands. The shell rewinds its input as much as possible and searches for a
79 line of the form \fIlabel\fR\fB:\fR possibly preceded by space or tab
80 characters. Execution continues after the indicated line. It is an error to
81 jump to a label that occurs between a \fBwhile\fR or \fBfor\fR built-in command
82 and its corresponding \fBend\fR.
86 \fBexit\fR causes the calling shell or shell script to exit with the exit
87 status specified by \fIn\fR. The value is the least significant 8 bits of the
88 specified status. If \fIn\fR is omitted then the exit status is that of the
89 last command executed. When \fBexit\fR occurs when executing a trap, the last
90 command refers to the command that executed before the trap was invoked. An
91 end-of-file also causes the shell to exit except for a shell which has the
92 \fBignoreeof\fR option (See \fBset\fR below) turned on.
95 \fBreturn\fR causes a shell function or \fB\&'.'\fR script to return to the
96 invoking script with the return status specified by \fIn\fR. The value is the
97 least significant 8 bits of the specified status. If \fIn\fR is omitted then
98 the return status is that of the last command executed. If \fBreturn\fR is
99 invoked while not in a function or a \fB\&'.'\fR script, then it is the same as
103 On this man page, \fBksh\fR(1) commands that are preceded by one or two \fB*\fR
104 (asterisks) are treated specially in the following ways:
108 Variable assignment lists preceding the command remain in effect when the
114 \fBI/O\fR redirections are processed after variable assignments.
119 Errors cause a script that contains them to abort.
124 Words, following a command preceded by \fB**\fR that are in the format of a
125 variable assignment, are expanded with the same rules as a variable assignment.
126 This means that tilde substitution is performed after the \fB=\fR sign and word
127 splitting and file name generation are not performed.
132 \fBexit\fR is shell special built-in that causes the shell that invokes it to
133 exit. Before exiting the shell, if the \fBEXIT\fR trap is set, it is invoked.
136 If \fIn\fR is specified, it is used to set the exit status.
139 \fBreturn\fR is a shell special built-in that causes the function or dot script
140 that invokes it to exit. If \fBreturn\fR is invoked outside of a \fBfunction\fR
141 or dot script it is equivalent to \fBexit\fR.
144 If \fBreturn\fR is invoked inside a function defined with the \fBfunction\fR
145 reserved word syntax, then any \fBEXIT\fR trap set within the function is
146 invoked in the context of the caller before the function returns.
149 If \fIn\fR is specified, it is used to set the exit status.
152 On this manual page, \fBksh93\fR commands that are preceded by one or two
153 \fB+\fR symbols are special built-in commands and are treated specially in the
158 Variable assignment lists preceding the command remain in effect when the
164 I/O redirections are processed after variable assignments.
169 Errors cause a script that contains them to abort.
174 They are not valid function names.
179 Words following a command preceded by \fB++\fR that are in the format of a
180 variable assignment are expanded with the same rules as a variable assignment.
181 This means that tilde substitution is performed after the \fB=\fR sign and
182 field splitting and file name generation are not performed.
188 If \fIn\fR is specified for \fBexit\fR, the exit status is the least
189 significant eight bits of the value of \fIn\fR. Otherwise, the exit status is
190 the exit status of preceding command. When invoked inside a trap, the preceding
191 command means the command that invoked the trap.
194 If \fIn\fR is specified for \fBreturn\fR, the exit status is the least
195 significant eight bits of the value of \fIn\fR. Otherwise, the exit status is
196 the exit status of preceding command.
200 See \fBattributes\fR(5) for descriptions of the following attributes:
208 ATTRIBUTE TYPE ATTRIBUTE VALUE
214 \fBbreak\fR(1), \fBcsh\fR(1), \fBksh\fR(1), \fBksh93\fR(1), \fBsh\fR(1),