Is there a way to run a bash script with set -e, i.e., as if set -e were in the first line of the script? I know there is for example bash -x to emulate set -x, but I didn't see anything to emulate set -e.
bash can use any of the options that are valid with set as a command line option, so you can simply use
bash -e myScript
Here's the first sentence from the Options section of the man page (emphasis mine; I know I glossed over this sentence for a long time as well):
In addition to the single-character shell options documented in the description of the set builtin command, bash interprets the following options when it is invoked:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With