Debian Codegraph @

doc/exit.n

raw
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 .TH exit n "" Tcl "Tcl Built-In Commands"
9 .so man.macros
10 .BS
11 '\" Note: do not modify the .SH NAME line immediately below!
12 .SH NAME
13 exit \- End the application
14 .SH SYNOPSIS
15 \fBexit \fR?\fIreturnCode\fR?
16 .BE
17
18 .SH DESCRIPTION
19 .PP
20 Terminate the process, returning \fIreturnCode\fR to the
21 system as the exit status.
22 If \fIreturnCode\fR is not specified then it defaults
23 to 0.
24 .SH EXAMPLE
25 .PP
26 Since non-zero exit codes are usually interpreted as error cases by
27 the calling process, the \fBexit\fR command is an important part of
28 signaling that something fatal has gone wrong. This code fragment is
29 useful in scripts to act as a general problem trap:
30 .PP
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 exists 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 .SH "SEE ALSO"
49 exec(n)
50 .SH KEYWORDS
51 abort, exit, process