引自What is the difference between ‘set +e’ and ‘set -e’ in a bash script?
做一个合格的粘贴怪:
In bash, set +e is basically the default: If you get an error in a bash script, it normally barfs out an error to the system (this is called an exit code) but the script will continue running.
But if you want errors to cause the script immediately to exit then you can put set -e on a line to force your script to exit on errors from that point on.
*Using set -e should be carefully planned… you don’t want to stop on the first error and miss the second problem, which could something much worse:
(example)
set -e
dodge approaching car (*steering wheel error- abandon program, including the routine to slam on the breaks. You die.)