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'將所有錯誤(語法錯誤,非零輸出代碼)等價。 –
太棒了,那就是我一直在尋找的:)。你可以在你的答案中加入這個鏈接。 –