mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-01 04:40:38 +08:00
task 命令支持给脚本传参,使用 -- 分割,后面的参数都会传给脚本
例如 task x.js -n whyour,脚本就能接收到参数 -n whyour
This commit is contained in:
+17
-2
@@ -95,6 +95,21 @@ format_params() {
|
||||
fi
|
||||
fi
|
||||
# params=$(echo "$@" | sed -E 's/([^ ])&([^ ])/\1\\\&\2/g')
|
||||
|
||||
# 分割 task 内置参数和脚本参数
|
||||
task_shell_params=()
|
||||
script_params=()
|
||||
found_double_dash=false
|
||||
|
||||
for arg in "$@"; do
|
||||
if $found_double_dash; then
|
||||
script_params+=("$arg")
|
||||
elif [ "$arg" == "--" ]; then
|
||||
found_double_dash=true
|
||||
else
|
||||
task_shell_params+=("$arg")
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
init_begin_time() {
|
||||
@@ -119,8 +134,8 @@ if [[ $max_time ]]; then
|
||||
fi
|
||||
|
||||
format_params "$@"
|
||||
define_program "$@"
|
||||
handle_log_path "$@"
|
||||
define_program "${task_shell_params[@]}"
|
||||
handle_log_path "${task_shell_params[@]}"
|
||||
init_begin_time
|
||||
|
||||
eval . $dir_shell/otask.sh "$cmd"
|
||||
|
||||
Reference in New Issue
Block a user