1 | '\" |
---|
2 | '\" Copyright (c) 1993 The Regents of the University of California. |
---|
3 | '\" Copyright (c) 1994-1996 Sun Microsystems, Inc. |
---|
4 | '\" |
---|
5 | '\" See the file "license.terms" for information on usage and redistribution |
---|
6 | '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
7 | '\" |
---|
8 | '\" RCS: @(#) $Id: exit.n,v 1.9 2007/12/13 15:22:32 dgp Exp $ |
---|
9 | '\" |
---|
10 | .so man.macros |
---|
11 | .TH exit n "" Tcl "Tcl Built-In Commands" |
---|
12 | .BS |
---|
13 | '\" Note: do not modify the .SH NAME line immediately below! |
---|
14 | .SH NAME |
---|
15 | exit \- End the application |
---|
16 | .SH SYNOPSIS |
---|
17 | \fBexit \fR?\fIreturnCode\fR? |
---|
18 | .BE |
---|
19 | |
---|
20 | .SH DESCRIPTION |
---|
21 | .PP |
---|
22 | Terminate the process, returning \fIreturnCode\fR to the |
---|
23 | system as the exit status. |
---|
24 | If \fIreturnCode\fR is not specified then it defaults |
---|
25 | to 0. |
---|
26 | .SH EXAMPLE |
---|
27 | Since non-zero exit codes are usually interpreted as error cases by |
---|
28 | the calling process, the \fBexit\fR command is an important part of |
---|
29 | signaling that something fatal has gone wrong. This code fragment is |
---|
30 | useful in scripts to act as a general problem trap: |
---|
31 | .CS |
---|
32 | proc main {} { |
---|
33 | # ... put the real main code in here ... |
---|
34 | } |
---|
35 | |
---|
36 | if {[catch {main} msg options]} { |
---|
37 | puts stderr "unexpected script error: $msg" |
---|
38 | if {[info exist env(DEBUG)]} { |
---|
39 | puts stderr "---- BEGIN TRACE ----" |
---|
40 | puts stderr [dict get $options -errorinfo] |
---|
41 | puts stderr "---- END TRACE ----" |
---|
42 | } |
---|
43 | |
---|
44 | # Reserve code 1 for "expected" error exits... |
---|
45 | \fBexit\fR 2 |
---|
46 | } |
---|
47 | .CE |
---|
48 | |
---|
49 | .SH "SEE ALSO" |
---|
50 | exec(n) |
---|
51 | |
---|
52 | .SH KEYWORDS |
---|
53 | exit, process |
---|