0
我有一个bash代码,我在其中创建了一个在程序中调用的函数。我忘了,因为它的剧本扔了语法error.Following语句之一quotation mark
是代码:Bash不会退出语法错误
#function
write_errors()
{
#writes RIGHT TRUNCATION errors in bcp import
temp_file=$1
error_file=$2
stepName=$3
error_count=`fgrep -c "right truncation" ${error_file} "` #here is the extra quotation mark
...
}
#start of script
date
...
write_errors #syntax error happens here
...
date #these lines are executed
rm -f ${temp}
rm -f ${error_file}
...
#end of script
我的问题是在write_errors
语法错误,为什么庆典之后执行行之后语法错误发生?为什么不像其他语言那样在语法错误中退出?
感谢您的快速响应,但它为什么默认?如果程序没有退出语法错误,那么这种行为的需求是什么? –
@snyder这个页面应该有一些细节:http://mywiki.wooledge.org/BashFAQ/105默认情况下有'set -e'的警告,因为'bash'将所有错误(语法错误,非零输出代码)等价。 –
太棒了,那就是我一直在寻找的:)。你可以在你的答案中加入这个链接。 –