更新时间:2022-06-18 04:29:56
来自 help set
:
-e Exit immediately if a command exits with a non-zero status.
但有些人认为这是不好的做法(bash FAQ 和 irc freenode #bash FAQ 作者).推荐使用:
But it's considered bad practice by some (bash FAQ and irc freenode #bash FAQ authors). It's recommended to use:
trap 'do_something' ERR
在发生错误时运行do_something
函数.
to run do_something
function when errors occur.