Can “set -e” be disabled in a script?

∥☆過路亽.° 提交于 2020-06-17 12:54:39

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!