Revision 13239
Added by Aaron Marcuse-Kubitza over 10 years ago
trunk/lib/sh/util.sh | ||
---|---|---|
735 | 735 |
|
736 | 736 |
echo_eval() { echo_params; builtin eval "$@"; } |
737 | 737 |
|
738 |
# usage: redirs=(...); [cmd_name_log_inc=#] echo_redirs_cmd |
|
739 |
function echo_redirs_cmd() |
|
740 |
{ |
|
741 |
local cmd_name_log_inc="${cmd_name_log_inc-0}" |
|
742 |
|
|
743 |
# print <>file redirs before cmd, because they introduce it |
|
744 |
log+ "$cmd_name_log_inc" echo_cmd "$@" $( |
|
745 |
set -- "${redirs[@]}" # operate on ${redirs[@]} |
|
746 |
while test "$#" -gt 0 && starts_with '[<>][^&]' "$1" |
|
747 |
do log "$1 \\"; shift; done # log() will run *before* echo_cmd itself |
|
748 |
echo "$@" |
|
749 |
) |
|
750 |
} |
|
751 |
alias echo_redirs_cmd='"echo_redirs_cmd" "$@"' |
|
752 |
|
|
753 | 738 |
## vars |
754 | 739 |
|
755 | 740 |
echo_vars() # usage: echo_vars var... # only prints vars that are defined |
... | ... | |
989 | 974 |
|
990 | 975 |
disable_logging() { set_fds "$log_fd>/dev/null"; } |
991 | 976 |
|
977 |
# usage: redirs=(...); [cmd_name_log_inc=#] echo_redirs_cmd |
|
978 |
function echo_redirs_cmd() |
|
979 |
{ |
|
980 |
local cmd_name_log_inc="${cmd_name_log_inc-0}" |
|
981 |
|
|
982 |
# print <>file redirs before cmd, because they introduce it |
|
983 |
log+ "$cmd_name_log_inc" echo_cmd "$@" $( |
|
984 |
set -- "${redirs[@]}" # operate on ${redirs[@]} |
|
985 |
while test "$#" -gt 0 && starts_with '[<>][^&]' "$1" |
|
986 |
do log "$1 \\"; shift; done # log() will run *before* echo_cmd itself |
|
987 |
echo "$@" |
|
988 |
) |
|
989 |
} |
|
990 |
alias echo_redirs_cmd='"echo_redirs_cmd" "$@"' |
|
991 |
|
|
992 | 992 |
function redir() # usage: local redirs=(#<>...); redir cmd...; unset redirs |
993 | 993 |
# to view only explicitly-displayed errors: explicit_errors_only=1 script... |
994 | 994 |
{ |
Also available in: Unified diff
lib/sh/util.sh: moved echo_redirs_cmd() to right before redir() which uses it