开发者

Stop on first error [duplicate]

This question already has answers here: Closed 10 years ago.

The community reviewed whether to reopen this question 6 months ago and left it closed:

Original close reason(s) were not resolved

Possible Duplicate:

Automatic exit from bash shell script on error

How can I have bash stop on the first command failure, without putting stuff like this all through my code?

some_开发者_开发百科prog || exit 1
some_other_prog || exit 1


Maybe you want set -e:

www.davidpashley.com/articles/writing-robust-shell-scripts.html#id2382181:

This tells bash that it should exit the script if any statement returns a non-true return value. The benefit of using -e is that it prevents errors snowballing into serious issues when they could have been caught earlier. Again, for readability you may want to use set -o errexit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜