我有一个调用许多命令的Bash shell脚本.如果任何命令返回非零值,我希望shell脚本自动退出,返回值为1.
如果没有明确检查每个命令的结果,这可能吗?
例如
dosomething1 if [[ $? -ne 0 ]]; then exit 1 fi dosomething2 if [[ $? -ne 0 ]]; then exit 1 fi
unix linux bash shell
bash ×1
linux ×1
shell ×1
unix ×1