Project

General

Profile

« Previous | Next » 

Revision 8978

lib/util.sh: exceptions: added save_e

View differences:

lib/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