task 命令增加 -m 参数,支持设置任务超时时间

This commit is contained in:
whyour 2022-12-01 18:26:24 +08:00
parent 5886e78299
commit 8cf491b802

View File

@ -61,15 +61,21 @@ format_params() {
params=$(echo "$@" | sed -E 's/([^ ])&([^ ])/\1\\\&\2/g') params=$(echo "$@" | sed -E 's/([^ ])&([^ ])/\1\\\&\2/g')
} }
show_log="false" while getopts ":lm:" opt; do
while getopts ":l" opt; do
case $opt in case $opt in
l) l)
show_log="true" show_log="true"
;; ;;
m)
max_time="$OPTARG"
;;
esac esac
done done
[[ "$show_log" == "true" ]] && shift $(($OPTIND - 1)) [[ $show_log ]] && shift $(($OPTIND - 1))
if [[ $max_time ]]; then
shift $(($OPTIND - 1))
command_timeout_time="$max_time"
fi
format_params "$@" format_params "$@"
define_program "$@" define_program "$@"