Next: main misc, Previous: main function, Up: main [Contents][Index]
Some functions and global variables are provided to declare script’s exit codes. The MBFL
declares its own exit codes starting from 100
and decreasing; we should declare our exit
codes starting from 3
and increasing. The exit codes 0
and 1
are reserved for
the functions exit_because_success()
and exit_because_failure()
.
Wrapper for the exit
command that updates the internal state.
Set by mbfl_exit()
to the exit code this script is using. This variable might be accessed by
atexit commands to appropriately react to an error condition.
Return true if the script is exiting. This function might be called by a location command being run by an atexit command.
Declare an exit code with value code and identifier name.
For each of the codes declared with mbfl_main_declare_exit_code()
: create a function for the
exit
command using the numerical code; create an alias for the return
command using
the numerical code. For example, if a code is declared as:
mbfl_main_declare_exit_code 4 unexistent_file
a function is created with:
function exit_because_unexistent_file () { mbfl_exit 4; }
and an alias is created with:
alias return_because_unexistent_file='return 4'
the name of the function is the string exit_because_
followed by the exit code name; the name
of the alias is the string return_because_
followed by the exit code name. The function may
be used in the script to exit the process.
By default the exit code 0
is associated to the name success
and the exit code
1
is associated to the name failure
; so the following functions exist.
Exit the script with code 0
.
Return with code 0
.
Exit the script with code 1
.
Return with code 1
.
Exit the script with code 100
.
Return with code 100
.
Print the code associated to name.
Next: main misc, Previous: main function, Up: main [Contents][Index]