Revision 9177
Added by Aaron Marcuse-Kubitza almost 12 years ago
util.sh | ||
---|---|---|
60 | 60 |
# usage: try cmd...; ignore status; if catch status; then ...; fi; end_try |
61 | 61 |
|
62 | 62 |
function try() { e=0; "$@" || { export_e; true; }; } |
63 |
alias try='declare e; try ' # last space alias-expands next word
|
|
63 |
alias try='declare e; "try" ' # last space alias-expands next word
|
|
64 | 64 |
|
65 | 65 |
catch() { test "$e" -eq "$1"; e=0; } |
66 | 66 |
|
... | ... | |
280 | 280 |
case "$1" in command) echo_run_prep; local cmd_echoed=1;; esac |
281 | 281 |
(limit_stderr; "$@") || return |
282 | 282 |
} |
283 |
alias limit_stderr_cmd='limit_stderr_cmd ' # last space alias-expands next word
|
|
283 |
alias limit_stderr_cmd='"limit_stderr_cmd" ' #last space alias-expands next word
|
|
284 | 284 |
alias limit_stdout_cmd='stdout2stderr=1 limit_stderr_cmd ' |
285 | 285 |
# last space alias-expands next word |
286 | 286 |
|
... | ... | |
422 | 422 |
test ! "$if_not_exists" || require_not_exists "$stdout" || return 0 |
423 | 423 |
"$@" >"$stdout" || { save_e; log_e; rm "$stdout"; rethrow; } |
424 | 424 |
} |
425 |
alias to_file='to_file ' # last space alias-expands next word
|
|
425 |
alias to_file='"to_file" ' # last space alias-expands next word
|
|
426 | 426 |
|
427 | 427 |
run_args_cmd() # runs the command line args command |
428 | 428 |
{ |
Also available in: Unified diff
bugfix: lib/sh/util.sh: recursive aliases (i.e. aliases that call a command of the same name): use "" around the command name so it isn't reexpanded if the function using the alias is copied using copy_func(). (aliases will be reexpanded every time a function is redeclared since they appear unquoted in the function definition.) this is a bug in `declare -f` for which there is no fix, necessitating the "" alias workaround instead.