The following is a script I wrote on a Mac (using the bourne shell sh.) This is part of a larger script. The goal: I have a zip file where I know the names of the zipped files ahead of time. So I want to unzip the zip file into /tmp/sampleFolder.  I then want to be able to check that folder to ensure the filenames I expect are in there.For example, if one of the files in the zip is john.txt, I want to check that/tmp/sampleFolder/john.txtexists.The problem: Oddly enough, my check for the file's existence seems to take place BEFORE the unzip is complete.  I can fix this by adding set -e at the top of the script. Then all the commands in the script seem to execute sequentially. But I can't understand why this fixes it.I would appreciate:a.) Alternative solutions / explanation of why the check for file existence occurs before file gets unzippedb.) or an explanation of why set -e forces the script to execute sequentially. My research into set -e simply says the script is forced to exit if commands make a return other than 0.  However, instead of merely exiting, the script runs sequentially. So it seems there is something more to it. Thank you!#!/bin/shrm -rf /tmp/sampleFolderunzip ~/Desktop/myFile.zip -d /tmp/sampleFolderif [ ! -r /tmp/sampleFolder/john.txt ]; thenecho file not present!fi
shell script continues before file unzipped
bash;shell;shell script
I see no way for the statements in the posted script to get executed non-sequentially.The following is a script I wrote on a Mac (using the bourne shell sh.) This is part of a larger script.If there is really a problem, it's likely to be in the bigger script, that's why it's not present in the simplified example.