如何退出在bash的所有调用脚本? [英] How to exit all the calling scripts in bash?
本文介绍了如何退出在bash的所有调用脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可以说我有以下脚本
a.sh
echo in a
if test 1 -ne 2; then
echo oops
exit 1
fi
b.sh
echo in b
./a.sh
echo in b 2
在运行b.sh,我希望它退出,如果退出a.sh。
我该怎么做呢?
When running b.sh, I want it to exit if a.sh exited. How do I do this?
(电流输出是
in b
in a
oops
in b 2
而这不是我想要的)
And that's not what I want)
谢谢,
Rivka
Thanks, Rivka
推荐答案
命令的检查返回状态,对应的变量是 $?
。
或者,您可以使用命令短路||退出
check return status of a command, corresponding variable is $?
.
alternatively, you can short-circuit using command || exit
这篇关于如何退出在bash的所有调用脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文