修复 shell 未定义变量错误

This commit is contained in:
whyour 2024-08-31 20:23:37 +08:00
parent b508e97dc1
commit 459f465f3b
2 changed files with 4 additions and 3 deletions

View File

@ -269,6 +269,7 @@ check_file "${task_shell_params[@]}"
if [[ $isJsOrPythonFile == 'false' ]]; then if [[ $isJsOrPythonFile == 'false' ]]; then
run_task_before "${task_shell_params[@]}" run_task_before "${task_shell_params[@]}"
fi fi
set_u_on="false"
if set -o | grep -q 'nounset.*on'; then if set -o | grep -q 'nounset.*on'; then
set_u_on="true" set_u_on="true"
set +u set +u

View File

@ -451,9 +451,9 @@ handle_task_start() {
run_task_before() { run_task_before() {
. $file_task_before "$@" . $file_task_before "$@"
if [[ $task_before ]]; then if [[ ${task_before:=} ]]; then
echo -e "执行前置命令\n" echo -e "执行前置命令\n"
eval "$task_before" "$@" eval "${task_before%;}" "$@"
echo -e "\n执行前置命令结束\n" echo -e "\n执行前置命令结束\n"
fi fi
} }
@ -463,7 +463,7 @@ run_task_after() {
if [[ ${task_after:=} ]]; then if [[ ${task_after:=} ]]; then
echo -e "\n执行后置命令\n" echo -e "\n执行后置命令\n"
eval "$task_after" "$@" eval "${task_after%;}" "$@"
echo -e "\n执行后置命令结束" echo -e "\n执行后置命令结束"
fi fi
} }