Saturday, September 28, 2013

Bash doesn't quit on syntax error

Bash doesn't quit on syntax error

I have a bash code in which I have made a function which is called in the
program. I forgot to put a quotation mark in one of the statement because
of which the script threw a syntax error.Following is the code :
#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}
...

1 comment: