我希望脚本在测试中出现语法错误时退出,但是没有运气:
bash -n "$0" || exit # check script syntax
#set -xv
set -o nounset
set -o errexit
set -o pipefail # make pipes fail if one of the piped commands fails
if (( != 0 )); then # syntax error here
echo "after if"
fi
echo "should not reach this point, but indeed does"
输出为:
./testscript: line 8: ((: != 0 : syntax error: operand expected (error token is "!= 0 ")
should not reach this point, but indeed does
任何解决方案? 谢谢