1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
### Copyright (C) 1996 Per Zacho
### This program is free software; you can redistribute it and/or modify
### it under the terms of the GNU General Public License as published by
### the Free Software Foundation; either version 2 of the License, or
### (at your option) any later version.
###
### This program is distributed in the hope that it will be useful,
### but WITHOUT ANY WARRANTY; without even the implied warranty of
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
### GNU General Public License for more details.
###
### You should have received a copy of the GNU General Public License
### along with this program; if not, write to the Free Software
### Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
proc errorHandling {} {
# System<->Bash interface / Error handling
Desc "This configuration page will help you to setup how Bash is to react upon certain"\
"exceptions like unknown variables, failing to execute a command/program, etc."
ShortDesc "Error handling"
### Error handling ###
Header head1 -text "Error handling"\
-background gray\
-help "Setup of how Bash is to handle certain exceptions."
CheckBox nounset -text "Treat undefined variables as errors"\
-help "If you (or a script) try to read an undefined variable, Bash normally"\
"expand the variable to a null-string. If this option is checked, reading"\
"undefined variables will cause Bash to halt with a message \"unbound variable\""
CheckBox exitOnFail -text "Non-interactive shell exit if 'exec'-call fails"\
-default 1\
-help "If the built-in call \"exec\" fails, Bash will not exit in an"\
"interactive shell (e.g. your login-shell). But if you call shell scripts"\
"you can specify if the shell is to exit if the \"exec\"-call fails. It can"\
"be usefull to keep the shell when debugging shell scripts, but normally"\
"you would leave this option checked."
CheckBox errExit -text "Exit shell if 'simple' command fails"\
-help "A simple command is a command not part of a \"while\", \"until\" or \"if\";"\
"or part of a \"&&\" or \"||\"; or a command whose return value is inverted by \"!\"."
CheckBox shiftErr -text "Halt if 'shift'-ing exceeds number of arguments"\
-help "If checked, the \"shift\" built-in prints an error message when the shift"\
"count exceeds the number of positional parameters. (This option is available"\
"in Bash version 2.0 only)"
ShowPage {
if {[set version@bash(index)]} {
Enable shiftErr
} {
Disable shiftErr
}
}
Save {
### Error handling ###
if {$nounset || $generateDefault} {
print "set [pick $nounset - +]o nounset"
}
if {$exitOnFail != 1 || $generateDefault} {
if [set version@bash(index)] {
print "shopt -[pick $exitOnFail u s] execfail"
} {
print "[pick $exitOnFail "unset no_exit_on_failed_exec" "export no_exit_on_failed_exec=on"]"
}
}
if {$errExit || $generateDefault} {
print "set [pick $errExit - +]o errexit"
}
if {($shiftErr || $generateDefault) && [set version@bash(index)]} {
print "shopt -[pick $shiftErr s u] shift_verbose"
}
}
}
|