Revision 9551
Added by Aaron Marcuse-Kubitza over 11 years ago
util.sh | ||
---|---|---|
131 | 131 |
|
132 | 132 |
ignore() { save_e; ignore_e "$@"; rethrow; } # usage: try cmd || ignore status |
133 | 133 |
|
134 |
### signals |
|
135 |
|
|
136 |
sig_e() { echo $(( 128+$(kill -l "$1") )); } # usage: sig_e SIGINT, etc. |
|
137 |
|
|
138 |
ignore_sig() { ignore "$(sig_e "$1")"; } |
|
139 |
|
|
140 |
# usage: piped_cmd cmd1...|cmd2... (which doesn't read all its input) |
|
141 |
function piped_cmd() { "$@" || ignore_sig SIGPIPE; } |
|
142 |
alias piped_cmd='"piped_cmd" ' # last space alias-expands next word |
|
143 |
|
|
134 | 144 |
fi # load new aliases |
135 | 145 |
if self_being_included; then |
136 | 146 |
|
Also available in: Unified diff
lib/sh/util.sh: exceptions: added signals-related functions ignore_sig(), piped_cmd() and helper sig_e()