Move everything from /var/adm to /var/log
[unleashed.git] / share / man / man1 / exit.1
blob8732bfe2f2447c65aa2c829ad919ba4e7449c5c9
1 '\" te
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"
9 .SH NAME
10 exit, return, goto \- shell built-in functions to enable the execution of the
11 shell to advance beyond its sequence of steps
12 .SH SYNOPSIS
13 .SS "sh"
14 .LP
15 .nf
16 \fBexit\fR [\fIn\fR]
17 .fi
19 .LP
20 .nf
21 \fBreturn\fR [\fIn\fR]
22 .fi
24 .SS "csh"
25 .LP
26 .nf
27 \fBexit\fR [( \fIexpr\fR )]
28 .fi
30 .LP
31 .nf
32 \fBgoto\fR \fIlabel\fR
33 .fi
35 .SS "ksh"
36 .LP
37 .nf
38 \fB*exit\fR [\fIn\fR]
39 .fi
41 .LP
42 .nf
43 \fB*return\fR [\fIn\fR]
44 .fi
46 .SS "ksh93"
47 .LP
48 .nf
49 \fB+exit\fR [\fIn\fR]
50 .fi
52 .LP
53 .nf
54 \fB+return\fR [\fIn\fR]
55 .fi
57 .SH DESCRIPTION
58 .SS "sh"
59 .sp
60 .LP
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.)
64 .sp
65 .LP
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
68 executed.
69 .SS "csh"
70 .sp
71 .LP
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
74 \fBexpr\fR.
75 .sp
76 .LP
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.
83 .SS "ksh"
84 .sp
85 .LP
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.
93 .sp
94 .LP
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
100 an \fBexit\fR.
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:
105 .RS +4
108 Variable assignment lists preceding the command remain in effect when the
109 command completes.
111 .RS +4
114 \fBI/O\fR redirections are processed after variable assignments.
116 .RS +4
119 Errors cause a script that contains them to abort.
121 .RS +4
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.
129 .SS "ksh93"
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
154 following ways:
155 .RS +4
158 Variable assignment lists preceding the command remain in effect when the
159 command completes.
161 .RS +4
164 I/O redirections are processed after variable assignments.
166 .RS +4
169 Errors cause a script that contains them to abort.
171 .RS +4
174 They are not valid function names.
176 .RS +4
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.
184 .SH EXIT STATUS
185 .SS "ksh93"
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.
197 .SH ATTRIBUTES
200 See \fBattributes\fR(5) for descriptions of the following attributes:
205 box;
206 c | c
207 l | l .
208 ATTRIBUTE TYPE  ATTRIBUTE VALUE
211 .SH SEE ALSO
214 \fBbreak\fR(1), \fBcsh\fR(1), \fBksh\fR(1), \fBksh93\fR(1), \fBsh\fR(1),
215 \fBattributes\fR(5)