views:

36

answers:

1

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 of 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?

+1  A: 

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.

jspcal
I thought so. Thanks for replying!
yyy