Revision 8971
Added by Aaron Marcuse-Kubitza almost 12 years ago
lib/util.sh | ||
---|---|---|
9 | 9 |
|
10 | 10 |
self_not_included () # usage: if self_not_included; then ... fi |
11 | 11 |
{ |
12 |
test "$#" -ge 1 || set -- "${BASH_SOURCE[1]}"
|
|
12 |
test $# -ge 1 || set -- "${BASH_SOURCE[1]}"
|
|
13 | 13 |
local include_guard="$(include_guard_var "$1")" |
14 | 14 |
alias self_being_included=false |
15 | 15 |
test -z "${!include_guard+t}" && \ |
... | ... | |
32 | 32 |
|
33 | 33 |
# usage: try cmd...; ignore status; if catch status; then ...; fi; end_try |
34 | 34 |
|
35 |
try_ () { { "$@"; e="$?";} || true; }
|
|
35 |
try_ () { { "$@"; e=$?;} || true; }
|
|
36 | 36 |
alias try='declare e; try_ ' # last space alias-expands next word |
37 | 37 |
|
38 | 38 |
catch () { test "$e" -eq "$1"; e=0; } |
... | ... | |
190 | 190 |
|
191 | 191 |
run_args_cmd () # runs the command line args command |
192 | 192 |
{ |
193 |
test "$?" -eq 0 || return
|
|
193 |
test $? -eq 0 || return
|
|
194 | 194 |
eval set -- "$(reverse "${BASH_ARGV[@]}")" |
195 |
test "$#" -ge 1 || set -- all
|
|
195 |
test $# -ge 1 || set -- all
|
|
196 | 196 |
echo_cmd "$(canon_rel_path "$0")" "$@"; "$@" |
197 | 197 |
} |
198 | 198 |
|
Also available in: Unified diff
lib/util.sh: removed "" around $?, $# because they are guaranteed to always be non-empty and contain no special chars