I'm using bash shell on Amazon Linux.  I can't figure out why my script is dying with a syntax error.  My script ends like sochmod 775 $TFILE2output_file=$( create_test_results_file $TFILE2 )(cat $TFILE2; uuencode $output_file $output_file) | mailx -s $subject $to_emailrm $output_fileecho sent second email#Cleanuprm $TFILE1rm $TFILE2echo removed files# If node exited unsuccessfully, verify we alert the process above.if [ $rc1 != 0 ]; then exit $rc1 fiif [ $rc2 != 0 ]; then exit $rc2 fiand when I run it, it prints out the last two echo statements, but then seems to die after thatsent second emailremoved files/home/jboss/.jenkins/jobs/springboard/workspace/automated-tests/nodejs/run_tests.sh: line 86: syntax error: unexpected end of fileCan anyone tell me why its dying with the unexpected end of file error? 
Trying to exit script with a status code but getting unexpected end of file
bash;shell script;exit;syntax
The short answer is that fi needs to be a separate command, so you need semi-colons:if [ $rc1 != 0 ]; then exit $rc1; fiif [ $rc2 != 0 ]; then exit $rc2; fiYou should quote your variables, and since youre comparing integers, use the appropriate operator:if [ $rc1 -ne 0 ]; then exit $rc1; fiif [ $rc2 -ne 0 ]; then exit $rc2; fialthough the behaviour here is slightly different: empty values will be considered equal to 0 (where != would consider them different).