exit(3tcl)

πŸ“¦
version 9.0.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ exit β€” end the application, bestie ✨

okay so this is from the Tcl Built-In Commands manual, section 3tcl, and it's literally the "bye girl" button of the whole process. πŸŽ€


🌸 NAME 🌸

exit β€” end the application πŸ’…


✨ SYNOPSIS ✨

exit ?returnCode?

πŸ’– DESCRIPTION πŸ’–

So here's the tea: exit terminates the process. Like, the whole thing. Gone. Done. It hands returnCode back to the system as the exit status, which is how the outside world finds out how things went. πŸ¦‹

And if you don't give it a returnCode? It just defaults to 0. Easy. Chill. No drama. ✨


πŸŽ€ EXAMPLE πŸŽ€

ngl this is the important part. Because non-zero exit codes are usually read by the calling process as "something went wrong," the exit command is lowkey a whole big deal β€” it's how you signal that something fatal has gone down. 😭

This code fragment is useful in scripts to act as a general problem trap:

proc main {} {
    # ... put the real main code in here ...
}

if {[catch {main} msg options]} {
    puts stderr "unexpected script error: $msg"
    if {[info exists env(DEBUG)]} {
        puts stderr "---- BEGIN TRACE ----"
        puts stderr [dict get $options -errorinfo]
        puts stderr "---- END TRACE ----"
    }

    # Reserve code 1 for "expected" error exits...
    exit 2
}

see how it reserves code 1 for "expected" error exits and busts out exit 2 for the truly unexpected chaos? iconic behavior, fr fr πŸ‘‘


🫢 SEE ALSO 🫢


πŸ’œ KEYWORDS πŸ’œ

  • abort
  • exit
  • process

reminder bestie: exit ends the whole process, not just your script. there is no coming back from this one. no cap. πŸ’€

mwah πŸ’‹ that's the whole page, sourced straight from the Tcl exit(3tcl) manual β€” Tcl version, exit(3tcl), that's the one. πŸŒˆβ­πŸ“πŸ§š

πŸ“¦ where this page comes from