Revision 9535
Added by Aaron Marcuse-Kubitza over 11 years ago
lib/sh/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' |
lib/sh/archives.sh | ||
---|---|---|
9 | 9 |
{ |
10 | 10 |
echo_func |
11 | 11 |
cmd_log_fd=1 try self "$@" |
12 |
ignore 12 # "zip has nothing to do" (`man zip`) |
|
12 |
ignore_e 12 # "zip has nothing to do" (`man zip`)
|
|
13 | 13 |
end_try |
14 | 14 |
} |
15 | 15 |
|
Also available in: Unified diff
lib/sh/util.sh: ignore(): renamed to ignore_e() so ignore() can be used for a simpler, ||-based command