【问题标题】:How to catch errors or exceptions in Csh?如何在 Csh 中捕获错误或异常?
【发布时间】:2015-09-21 16:31:30
【问题描述】:

我想知道是否有办法捕捉异常并在发生这种情况时控制流程。 例如运行这一行,我想知道是否发生了shell错误。

source /scripts/scriptThatWillFail.csh

【问题讨论】:

    标签: linux shell csh


    【解决方案1】:

    退出/返回代码存储在 C shell 中的 status 变量中。

    source /scripts/scriptThatWillFail.csh
    if ($status != 0) then
        echo failed
    else
        echo passed
    endif
    

    【讨论】:

      猜你喜欢
      • 2010-12-14
      • 2012-02-01
      • 2011-08-25
      • 2019-09-08
      • 2015-06-11
      • 2020-06-15
      • 2018-10-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多