Revision 12771
Added by Aaron Marcuse-Kubitza almost 11 years ago
trunk/lib/sh/util.sh | ||
---|---|---|
229 | 229 |
|
230 | 230 |
# usage: try cmd...; ignore_e status; if catch status; then ...; fi; end_try |
231 | 231 |
|
232 |
alias prep_try='declare e' # last space alias-expands next word |
|
232 |
alias prep_try='declare e=0' # last space alias-expands next word
|
|
233 | 233 |
|
234 | 234 |
# usage: ...; try cmd... # *MUST* be at beginning of statement |
235 | 235 |
# OR prep_try; wrapper "try" cmd... |
236 |
function try() { e=0; benign_error=1 "$@" || { export_e; true; }; }
|
|
236 |
function try() { benign_error=1 "$@" || { export_e; true; }; } |
|
237 | 237 |
alias try='prep_try; "try" ' # last space alias-expands next word |
238 | 238 |
|
239 | 239 |
catch() { test "$e" -eq "$1" && e=0; } |
Also available in: Unified diff
lib/sh/util.sh: prep_try: initialize $e to 0 to simplify error-handling coding