当jarinside抛出错误时,如何停止shell代码的执行?

当jarinside抛出错误时,如何停止shell代码的执行?,shell,Shell,我有一个通过shell脚本运行的jar。但是,如果jar抛出一些错误,我们应该更新jar。在这种情况下,shell脚本将继续处理下一行,错误将丢失在日志中 当jar抛出错误时,我可以停止shell脚本的执行吗 cd correctDirectory ....../bin/java -cp myjar.jar package.mainclass #The below should not execute when the above jar throws an error. Number=$(wc

我有一个通过shell脚本运行的jar。但是,如果jar抛出一些错误,我们应该更新jar。在这种情况下,shell脚本将继续处理下一行,错误将丢失在日志中

当jar抛出错误时,我可以停止shell脚本的执行吗

cd correctDirectory
....../bin/java -cp myjar.jar package.mainclass
#The below should not execute when the above jar throws an error.
Number=$(wc -l outputOfJar.txt)
#insert the above number in DB which if is less than a threshold generates me an alert
#But this is not so effective.

你能把你的shell代码粘贴到你的帖子里吗?看看set-e选项,在处理任何错误时shell停止。祝你好运