Revision 8886
Added by Aaron Marcuse-Kubitza over 11 years ago
lib/util.sh | ||
---|---|---|
24 | 24 |
|
25 | 25 |
shopt -s expand_aliases |
26 | 26 |
|
27 |
#### exceptions |
|
28 |
|
|
29 |
# usage: try cmd...; ignore status; if catch status; then ...; fi; end_try |
|
30 |
|
|
31 |
try_ () { { "$@"; e="$?";} || true; } |
|
32 |
alias try='local e; try_ ' # trailing space alias-expands next word |
|
33 |
|
|
34 |
catch () { test "$e" -eq "$1"; e=0; } |
|
35 |
|
|
36 |
ignore () { catch "$@" || true; } |
|
37 |
|
|
38 |
alias end_try='return "$e"' |
|
39 |
|
|
27 | 40 |
#### arrays |
28 | 41 |
|
29 | 42 |
join () { local IFS="$delim"; echo "$*"; } # usage: delim=... join elems... |
Also available in: Unified diff
lib/util.sh: added exception-handling (i.e. error-suppressing) functions