Revision 8978
Added by Aaron Marcuse-Kubitza over 11 years ago
util.sh | ||
---|---|---|
33 | 33 |
alias rethrow='return "$e"' |
34 | 34 |
alias rethrow_subshell='exit "$e"' |
35 | 35 |
|
36 |
fi # load new aliases |
|
37 |
if self_being_included; then |
|
38 |
|
|
39 |
# usage: save_e cmd... || use $e (or $?) |
|
40 |
function save_e () { "$@"; e=$?; rethrow; } # rethrow because e= clears $? |
|
41 |
alias save_e='declare e; save_e ' # last space alias-expands next word |
|
42 |
|
|
36 | 43 |
# usage: try cmd...; ignore status; if catch status; then ...; fi; end_try |
37 | 44 |
|
38 | 45 |
try_ () { { "$@"; e=$?;} || true; } |
Also available in: Unified diff
lib/util.sh: exceptions: added save_e