问题
I want to do something like this in a shell script main.sh. Is it possible?
set -e
******some code
unset -e
******some other code.
set -e
回答1:
@Charles Duffy on another thread answered this. not exit a bash script when one of the sub-script fails
set +e undoes set -e. However, using set -e is a bad idea in general; better to use || exit on individual commands where you want a nonzero exit status to be fatal. (Skip past the parable to the exercises if you're in a hurry). – Charles Duffy
来源:https://stackoverflow.com/questions/62185918/can-set-e-be-disabled-in-a-script