From 802b2d722efec45a61358eb01dfb0dabf7daec86 Mon Sep 17 00:00:00 2001 From: whyour Date: Wed, 2 Nov 2022 18:51:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=BB=E5=8A=A1=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E4=B8=AD=E7=9A=84&=E5=92=8C=E5=BC=95=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/otask.sh | 3 +-- shell/task.sh | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/shell/otask.sh b/shell/otask.sh index b849c511..4fd2be71 100644 --- a/shell/otask.sh +++ b/shell/otask.sh @@ -232,8 +232,7 @@ run_else() { shift - local params=$(echo "$@" | sed 's/ /\" \"/g') - $timeoutCmd $which_program $file_param \"$params\" + $timeoutCmd $which_program $file_param "$@" } ## 命令检测 diff --git a/shell/task.sh b/shell/task.sh index 518e98f2..375f529c 100755 --- a/shell/task.sh +++ b/shell/task.sh @@ -58,6 +58,7 @@ format_params() { if type timeout &>/dev/null; then timeoutCmd="timeout -k 10s $command_timeout_time " fi + params=$(echo "$@" | sed 's/&/\\&/g') } show_log="false" @@ -70,10 +71,11 @@ while getopts ":l" opt; do done [[ "$show_log" == "true" ]] && shift $(($OPTIND - 1)) -format_params -define_program "$@" -handle_log_path "$@" -eval . $dir_shell/otask.sh "$@" "$cmd" +format_params "$@" +define_program "$params" +handle_log_path "$params" + +eval . $dir_shell/otask.sh "$params" "$cmd" [[ -f "$dir_log/$log_path" ]] && cat "$dir_log/$log_path" exit 0