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.
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:
Very useful, it’ll save you lot of tedious if’s and error checking.