Failure in a bash script usually means failure of the script
So, when you write a bash script that does a certain amount of tasks for you, but you don't want the script to keep running after some command inside the script failed, simply add a line to the script.
#!bash set -e
Quoting the man page:
Exit immediately if a simple command exits with a non-zero, unless the command that fails is part of an until or loop, part of an if statement, part of a && or || list, if the command's return is being inverted using !.
If you want to reset to normal behaviour, reverse it using:
#!bash set +e
Very useful, it'll save you lot of tedious if's and error checking.
< Return to main page