Revision 9655
Added by Aaron Marcuse-Kubitza over 11 years ago
util.sh | ||
---|---|---|
412 | 412 |
|
413 | 413 |
echo_eval() { echo_params; builtin eval "$@"; } |
414 | 414 |
|
415 |
# usage: redirs=(...); echo_redirs_cmd |
|
416 |
function echo_redirs_cmd() |
|
417 |
{ |
|
418 |
( |
|
419 |
# print <>file redirs before cmd, because they introduce it |
|
420 |
local file_redirs=() |
|
421 |
while test "${#redirs[@]}" -gt 0 && starts_with '[<>][^&]' "${redirs[0]}" |
|
422 |
do |
|
423 |
file_redirs+=("${redirs[0]} \\ |
|
424 |
") |
|
425 |
redirs=("${redirs[@]:1}") |
|
426 |
done |
|
427 |
echo_cmd "${file_redirs[@]}$@" "${redirs[@]}" |
|
428 |
) |
|
429 |
} |
|
430 |
alias echo_redirs_cmd='"echo_redirs_cmd" "$@"' |
|
431 |
|
|
415 | 432 |
## vars |
416 | 433 |
|
417 | 434 |
echo_vars() # usage: echo_vars var... |
... | ... | |
587 | 604 |
fi |
588 | 605 |
fi |
589 | 606 |
|
590 |
cmd2rel_path |
|
607 |
cmd2rel_path; echo_redirs_cmd
|
|
591 | 608 |
|
592 |
# print cmd |
|
593 |
( |
|
594 |
# print <>file redirs before cmd, because they introduce it |
|
595 |
local file_redirs=() |
|
596 |
while test "${#redirs[@]}" -gt 0 && starts_with '[<>][^&]' "${redirs[0]}" |
|
597 |
do |
|
598 |
file_redirs+=("${redirs[0]} \\ |
|
599 |
") |
|
600 |
redirs=("${redirs[@]:1}") |
|
601 |
done |
|
602 |
echo_cmd "${file_redirs[@]}$@" "${redirs[@]}" |
|
603 |
) |
|
604 |
|
|
605 | 609 |
# add after echoing command so it isn't echoed at the end of every command |
606 | 610 |
if test "$cmd_log_fd" != 2; then # fd 2 not used for logging |
607 | 611 |
redirs+=("2>&$err_fd") # assume fd 2 used for errors |
Also available in: Unified diff
lib/sh/util.sh: added echo_redirs_cmd and use it in command() to print cmd