Revision 9034
Added by Aaron Marcuse-Kubitza over 11 years ago
lib/sh/util.sh | ||
---|---|---|
57 | 57 |
function log_e () # usage: log_e cmd... [ || use $e (or $?) ] |
58 | 58 |
{ |
59 | 59 |
if "$@"; then :; else # don't use ! because that resets $? |
60 |
export_e
|
|
60 |
save_e
|
|
61 | 61 |
echo "! $*" >&2 |
62 | 62 |
echo "! command exited with error $e" >&2 |
63 | 63 |
rethrow |
64 | 64 |
fi |
65 | 65 |
} |
66 |
alias log_e='declare e; log_e ' # last space alias-expands next word
|
|
66 |
alias log_e='log_e ' # last space alias-expands next word |
|
67 | 67 |
|
68 | 68 |
# usage: try cmd...; ignore status; if catch status; then ...; fi; end_try |
69 | 69 |
|
Also available in: Unified diff
lib/sh/util.sh: log_e (): don't export $e to the calling context, since the caller can just use ` || { save_e; ...; }` if they need $e