问题:
I'm writing a script in Bash to test some code. 我正在Bash中编写脚本来测试一些代码。 However, it seems silly to run the tests if compiling the code fails in the first place, in which case I'll just abort the tests. 但是,如果编译代码首先失败,则运行测试似乎很愚蠢,在这种情况下,我将中止测试。
Is there a way I can do this without wrapping the entire script inside of a while loop and using breaks? 有没有一种方法可以在不将整个脚本包装在while循环内并使用break的情况下做到这一点? Something like a dun dun dun goto? 像dun dun dun goto之类的东西?
解决方案:
参考一: https://stackoom.com/question/5mYE/在Bash脚本中-如果发生某种情况-如何退出整个脚本参考二: https://oldbug.net/q/5mYE/In-a-Bash-script-how-can-I-exit-the-entire-script-if-a-certain-condition-occurs
来源:oschina
链接:https://my.oschina.net/u/3797416/blog/4270813