Revision 9535
Added by Aaron Marcuse-Kubitza over 11 years ago
util.sh | ||
---|---|---|
117 | 117 |
fi # load new aliases |
118 | 118 |
if self_being_included; then |
119 | 119 |
|
120 |
# usage: try cmd...; ignore status; if catch status; then ...; fi; end_try |
|
120 |
# usage: try cmd...; ignore_e status; if catch status; then ...; fi; end_try
|
|
121 | 121 |
|
122 | 122 |
function try() { e=0; benign_error=1 "$@" || { export_e; true; }; } |
123 | 123 |
alias try='declare e; "try" ' # last space alias-expands next word |
124 | 124 |
|
125 | 125 |
catch() { test "$e" -eq "$1" && e=0; } |
126 | 126 |
|
127 |
ignore() { catch "$@" || true; } |
|
127 |
ignore_e() { catch "$@" || true; }
|
|
128 | 128 |
|
129 | 129 |
alias end_try='rethrow' |
130 | 130 |
alias end_try_subshell='rethrow_subshell' |
Also available in: Unified diff
lib/sh/util.sh: ignore(): renamed to ignore_e() so ignore() can be used for a simpler, ||-based command