I use set -e in scripts quite often, but sometimes, it's ok for a script to fail in some of it's commands.
I tried checking if set -e was ON, but couldn't find a way to do it - there's no option (that I know of) in set that will provide the current value.
Also tried this:
set | grep errexit (errexit is the option name for -e) and set | grep "-e", no luck there.
I would like to check if the errexit option is set, so I could temporarily disable it in some of my library functions that I built over time (using set +e and re-applying set -e if needed).
Something like:
if [ errexit is set ]; then
ERR_EXIT=1
set +e
fi
...
run some code that may fail
...
if [ "${ERR_EXIT}" = 1 ]; then
set -e
fi