Stop on first error
本问题已经有最佳答案,请猛点这里访问。
Possible Duplicate:
Automatic exit from bash shell script on error
在第一次命令失败时,我怎么能让bash停止,而不把这样的东西都放到我的代码中呢?
1 2 | some_prog || exit 1 some_other_prog || exit 1 |
也许你想要
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.