1exit(n) Tcl Built-In Commands exit(n)
2
3
4
5______________________________________________________________________________
6
8 exit - End the application
9
11 exit ?returnCode?
12_________________________________________________________________
13
14
16 Terminate the process, returning returnCode to the system as the exit
17 status. If returnCode is not specified then it defaults to 0.
18
20 Since non-zero exit codes are usually interpreted as error cases by the
21 calling process, the exit command is an important part of signaling
22 that something fatal has gone wrong. This code fragment is useful in
23 scripts to act as a general problem trap:
24 proc main {} {
25 # ... put the real main code in here ...
26 }
27
28 if {[catch {main} msg options]} {
29 puts stderr "unexpected script error: $msg"
30 if {[info exist env(DEBUG)]} {
31 puts stderr "---- BEGIN TRACE ----"
32 puts stderr [dict get $options -errorinfo]
33 puts stderr "---- END TRACE ----"
34 }
35
36 # Reserve code 1 for "expected" error exits...
37 exit 2
38 }
39
40
42 exec(n)
43
44
46 exit, process
47
48
49
50Tcl exit(n)