Revision 9657
Added by Aaron Marcuse-Kubitza over 11 years ago
lib/sh/util.sh | ||
---|---|---|
415 | 415 |
# usage: redirs=(...); echo_redirs_cmd |
416 | 416 |
function echo_redirs_cmd() |
417 | 417 |
{ |
418 |
( |
|
419 |
# print <>file redirs before cmd, because they introduce it |
|
420 |
while test "${#redirs[@]}" -gt 0 && starts_with '[<>][^&]' "${redirs[0]}" |
|
421 |
do |
|
422 |
log "${redirs[0]} \\" |
|
423 |
redirs=("${redirs[@]:1}") |
|
424 |
done |
|
425 |
echo_cmd "$@" "${redirs[@]}" |
|
418 |
# print <>file redirs before cmd, because they introduce it |
|
419 |
echo_cmd "$@" $( |
|
420 |
set -- "${redirs[@]}" # operate on @redirs |
|
421 |
while test "$#" -gt 0 && starts_with '[<>][^&]' "$1" |
|
422 |
do log "$1 \\"; shift; done # log() will run *before* echo_cmd itself |
|
423 |
echo "$@" |
|
426 | 424 |
) |
427 | 425 |
} |
428 | 426 |
alias echo_redirs_cmd='"echo_redirs_cmd" "$@"' |
Also available in: Unified diff
lib/sh/util.sh: echo_redirs_cmd(): use $
in a subshell instead of manipulating the @redirs array directly, because operations on $
(e.g. $#, $1, shift) are much simpler than the corresponding array operations ( ${#redirs[]}, ${redirs[0]}, redirs=("${redirs[
]:1}") )