Bash - Immediately exit a script when it encounters an error: set -e
set -e causes a script immediately exits when it encounters an error. If one of the commands (or executables) that the script calls, returns a non-zero value, this is considered an error.
echo "\$-=$-"
set -e
echo "\$-=$-"
echo "This is script 2, \$-=$-"
ls this-file-does-not-exist
echo "This echo won't be executed because the -e of ./run.sh stops the execution upon encountering an error"