什么是$?在shell中表示if语句?

时间:2013-10-22 08:16:24

标签: shell csh

shell脚本中以下语句的含义是什么?

if ($?REGRESS) then
....
endif

给定函数从哪里输入?这是我无法理解的旧脚本的一部分。

2 个答案:

答案 0 :(得分:2)

csh手册页:

$?name
${?name}
    Substitutes the string `1' if name is set, `0' if it is not.

但请停止使用csh(对未来读者的强制性评论可能会错过使用csh对您健康有害的备忘录)。

答案 1 :(得分:0)

$?是一个特殊的变量。它存储最后一个命令的退出状态。如果最后一个命令成功运行,则它将为0,其他一些值为失败。

相关问题