Revision 9041
Added by Aaron Marcuse-Kubitza over 11 years ago
lib/sh/util.sh | ||
---|---|---|
96 | 96 |
|
97 | 97 |
#### integers |
98 | 98 |
|
99 |
let () { builtin let "$@" || true; }
|
|
99 |
let! () { let "$@" || true; } # always returns true; safe to use for setting
|
|
100 | 100 |
# "If the last ARG evaluates to 0, let returns 1" (`help let`) |
101 | 101 |
|
102 | 102 |
bool2int () { try test -z "$1"; echo "$e"; } # empty->0; non-empty->1 |
... | ... | |
144 | 144 |
# usage: in func: inc_log_level; ... |
145 | 145 |
# outside func: inc_log_level; ...; dec_log_level |
146 | 146 |
alias inc_log_level='declare verbosity="$verbosity" PS4="$log_indent$PS4" |
147 |
let verbosity--' |
|
147 |
let! verbosity--'
|
|
148 | 148 |
alias dec_log_level='declare verbosity="$verbosity" PS4="${PS4#$log_indent}" |
149 |
let verbosity++' |
|
149 |
let! verbosity++'
|
|
150 | 150 |
|
151 | 151 |
fi # load new aliases |
152 | 152 |
if self_being_included; then |
Also available in: Unified diff
lib/sh/util.sh: let (): renamed to let! so that let can still be used to evaluate whether a numeric value is 0 (yes, an ! is allowed at the end of a command name)