Revision 8982
Added by Aaron Marcuse-Kubitza over 11 years ago
lib/util.sh | ||
---|---|---|
42 | 42 |
|
43 | 43 |
function log_e () # usage: log_e cmd... [ || use $e (or $?) ] |
44 | 44 |
{ |
45 |
if ! save_e "$@"; then
|
|
45 |
if ! "save_e" "$@"; then
|
|
46 | 46 |
echo "! $*" >&2 |
47 | 47 |
echo "! command exited with error $e" >&2 |
48 | 48 |
rethrow |
49 | 49 |
fi |
50 | 50 |
} |
51 |
alias log_e='log_e ' # last space alias-expands next word |
|
51 |
alias log_e='declare e; log_e ' # last space alias-expands next word
|
|
52 | 52 |
|
53 | 53 |
# usage: try cmd...; ignore status; if catch status; then ...; fi; end_try |
54 | 54 |
|
Also available in: Unified diff
bugfix: lib/util.sh: exceptions: log_e: must include `declare e` in the alias and not when save_e is called, so that $e is a local var of the caller. this bug did not appear in testing because the save_e alias, which re-scopes $e within log_e (), was not expanded inside log_e () (since new aliases were not loaded between save_e and log_e ()).