CSH集团存在测试与价值测试

时间:2010-10-15 13:42:54

标签: csh

在CSH中,是否可以将变量实例的测试嵌套在同一if子句中,并测试其值?

#!/bin/csh

# This seems to work...
if ( $?VAR ) then
    echo "VAR exists"        
    if ( $VAR == true ) then
        echo "VAR is true"
    endif
endif

# I want something more like this:
if (( $?VAR ) && ( $VAR == true )) then
    echo "VAR exists and is true"
endif

1 个答案:

答案 0 :(得分:2)

短路评估是many things that C shell doesn't do之一。您必须使用嵌套的if语句或切换shell。