Revision 12194
Added by Aaron Marcuse-Kubitza almost 11 years ago
trunk/lib/sh/util.sh | ||
---|---|---|
200 | 200 |
|
201 | 201 |
# usage: try cmd...; ignore_e status; if catch status; then ...; fi; end_try |
202 | 202 |
|
203 |
alias prep_try='declare e' # last space alias-expands next word |
|
204 |
|
|
205 |
# usage: ...; try cmd... # *MUST* be at beginning of statement |
|
206 |
# OR prep_try; wrapper "try" cmd... |
|
203 | 207 |
function try() { e=0; benign_error=1 "$@" || { export_e; true; }; } |
204 |
alias try='declare e; "try" ' # last space alias-expands next word
|
|
208 |
alias try='prep_try; "try" ' # last space alias-expands next word
|
|
205 | 209 |
|
206 | 210 |
catch() { test "$e" -eq "$1" && e=0; } |
207 | 211 |
|
Also available in: Unified diff
lib/sh/util.sh: added prep_try and use it in try alias. try: documented how to run it with a wrapper command.