mirror of
https://github.com/whyour/qinglong.git
synced 2025-07-07 20:06:08 +08:00
修复 shell 检查 nounset 变量
This commit is contained in:
parent
66706ce150
commit
2f70e10be7
|
@ -229,6 +229,17 @@ check_file() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_nounset() {
|
||||||
|
local output=$(set -o)
|
||||||
|
while read -r line; do
|
||||||
|
if [[ "$line" =~ "nounset" ]] && [[ "$line" =~ "on" ]]; then
|
||||||
|
set_u_on="true"
|
||||||
|
set +u
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done <<<"$output"
|
||||||
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
if [[ $1 == *.js ]] || [[ $1 == *.py ]] || [[ $1 == *.pyc ]] || [[ $1 == *.sh ]] || [[ $1 == *.ts ]]; then
|
if [[ $1 == *.js ]] || [[ $1 == *.py ]] || [[ $1 == *.pyc ]] || [[ $1 == *.sh ]] || [[ $1 == *.ts ]]; then
|
||||||
if [[ $1 == *.sh ]]; then
|
if [[ $1 == *.sh ]]; then
|
||||||
|
@ -270,10 +281,7 @@ if [[ $isJsOrPythonFile == 'false' ]]; then
|
||||||
run_task_before "${task_shell_params[@]}"
|
run_task_before "${task_shell_params[@]}"
|
||||||
fi
|
fi
|
||||||
set_u_on="false"
|
set_u_on="false"
|
||||||
if set -o | grep -q 'nounset.*on'; then
|
check_nounset
|
||||||
set_u_on="true"
|
|
||||||
set +u
|
|
||||||
fi
|
|
||||||
main "${task_shell_params[@]}"
|
main "${task_shell_params[@]}"
|
||||||
if [[ "$set_u_on" == 'true' ]]; then
|
if [[ "$set_u_on" == 'true' ]]; then
|
||||||
set -u
|
set -u
|
||||||
|
|
Loading…
Reference in New Issue
Block a user