1exit(1) User Commands exit(1)
2
3
4
6 exit, return, goto - shell built-in functions to enable the execution
7 of the shell to advance beyond its sequence of steps
8
10 sh
11 exit [n]
12
13
14 return [n]
15
16
17 csh
18 exit [( expr )]
19
20
21 goto label
22
23
24 ksh
25 *exit [n]
26
27
28 *return [n]
29
30
31 ksh93
32 +exit [n]
33
34
35 +return [n]
36
37
39 sh
40 exit causes the calling shell or shell script to exit with the exit
41 status specified by n. If n is omitted the exit status is that of the
42 last command executed (an EOF also causes the shell to exit.)
43
44
45 return causes a function to exit with the return value specified by n.
46 If n is omitted, the return status is that of the last command exe‐
47 cuted.
48
49 csh
50 exit causes the calling shell or shell script to exit, either with the
51 value of the status variable or with the value specified by the expres‐
52 sion expr.
53
54
55 The goto built-in uses a specified label as a search string amongst
56 commands. The shell rewinds its input as much as possible and searches
57 for a line of the form label: possibly preceded by space or tab charac‐
58 ters. Execution continues after the indicated line. It is an error to
59 jump to a label that occurs between a while or for built-in command and
60 its corresponding end.
61
62 ksh
63 exit causes the calling shell or shell script to exit with the exit
64 status specified by n. The value is the least significant 8 bits of the
65 specified status. If n is omitted then the exit status is that of the
66 last command executed. When exit occurs when executing a trap, the last
67 command refers to the command that executed before the trap was
68 invoked. An end-of-file also causes the shell to exit except for a
69 shell which has the ignoreeof option (See set below) turned on.
70
71
72 return causes a shell function or '.' script to return to the invoking
73 script with the return status specified by n. The value is the least
74 significant 8 bits of the specified status. If n is omitted then the
75 return status is that of the last command executed. If return is
76 invoked while not in a function or a '.' script, then it is the same as
77 an exit.
78
79
80 On this man page, ksh(1) commands that are preceded by one or two *
81 (asterisks) are treated specially in the following ways:
82
83 1. Variable assignment lists preceding the command remain in
84 effect when the command completes.
85
86 2. I/O redirections are processed after variable assignments.
87
88 3. Errors cause a script that contains them to abort.
89
90 4. Words, following a command preceded by ** that are in the
91 format of a variable assignment, are expanded with the same
92 rules as a variable assignment. This means that tilde sub‐
93 stitution is performed after the = sign and word splitting
94 and file name generation are not performed.
95
96 ksh93
97 exit is shell special built-in that causes the shell that invokes it to
98 exit. Before exiting the shell, if the EXIT trap is set, it is invoked.
99
100
101 If n is specified, it is used to set the exit status.
102
103
104 return is a shell special built-in that causes the function or dot
105 script that invokes it to exit. If return is invoked outside of a func‐
106 tion or dot script it is equivalent to exit.
107
108
109 If return is invoked inside a function defined with the function
110 reserved word syntax, then any EXIT trap set within the function is
111 invoked in the context of the caller before the function returns.
112
113
114 If n is specified, it is used to set the exit status.
115
116
117 On this manual page, ksh93 commands that are preceded by one or two +
118 symbols are special built-in commands and are treated specially in the
119 following ways:
120
121 1. Variable assignment lists preceding the command remain in
122 effect when the command completes.
123
124 2. I/O redirections are processed after variable assignments.
125
126 3. Errors cause a script that contains them to abort.
127
128 4. They are not valid function names.
129
130 5. Words following a command preceded by ++ that are in the
131 format of a variable assignment are expanded with the same
132 rules as a variable assignment. This means that tilde sub‐
133 stitution is performed after the = sign and field splitting
134 and file name generation are not performed.
135
137 ksh93
138 If n is specified for exit, the exit status is the least significant
139 eight bits of the value of n. Otherwise, the exit status is the exit
140 status of preceding command. When invoked inside a trap, the preceding
141 command means the command that invoked the trap.
142
143
144 If n is specified for return, the exit status is the least significant
145 eight bits of the value of n. Otherwise, the exit status is the exit
146 status of preceding command.
147
149 See attributes(5) for descriptions of the following attributes:
150
151
152
153
154 ┌─────────────────────────────┬─────────────────────────────┐
155 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
156 ├─────────────────────────────┼─────────────────────────────┤
157 │Availability │SUNWcsu │
158 └─────────────────────────────┴─────────────────────────────┘
159
161 break(1), csh(1), ksh(1), ksh93(1), sh(1), attributes(5)
162
163
164
165SunOS 5.11 2 Nov 2007 exit(1)