开发者

Using logical OR (||) in C-Shell

I have a C-Shell code where I use the following command:

if($#arr == 0 || $arr[1] == "test1") then

It outputs an error message saying "tcsh: arr: Subscript out o开发者_如何学运维f range." obviously because the first condition is true. Is it possible to force it to ignore the second condition if the first condition is true?


csh parses the entire line and substitutes variables before evaluating the expression. so in this case, you'd need a nested if because the or condition does not implement short-circuit evaluation with respect to variables.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜