本文介绍了BASH中的错误处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是你最喜欢的方法BASH来处理错误?
我已经在网络上发现了BASH处理错误的最好的例子是在)。

and $temp_foo will be deleted on exit, and the current line number will be printed. (set -e will likewise give you exit-on-error behavior, ).

您可以让中断调用错误你(在这种情况下,它使用默认的1退出code和无消息),或调用它自己,提供明确的价值;例如:

You can either let the trap call error for you (in which case it uses the default exit code of 1 and no message) or call it yourself and provide explicit values; for instance:

error ${LINENO} "the foobar failed" 2

将与状态2退出,并给出一个明确的信息。

will exit with status 2, and give an explicit message.

这篇关于BASH中的错误处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-19 05:29
查看更多