我正在编写一个bash脚本,该脚本应退出上一个失败命令的错误代码,而不继续执行。可以通过在|| exit $?
任何地方添加一个位置来实现,但是有没有更简单的方法,例如set
在开始时可以选择在不影响每一行的情况下执行此操作?
set -e
?
set: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
Set or unset values of shell options and positional parameters.
Change the value of shell attributes and positional parameters, or
display the names and values of shell variables.
Options:
-a Mark variables which are modified or created for export.
-b Notify of job termination immediately.
-e Exit immediately if a command exits with a non-zero status.
...
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句