开发者

CSH Group Existance Test With Value Test

开发者 https://www.devze.com 2023-01-20 06:54 出处:网络
In CSH, is it possible to nest the test for an existance of a variable with the test for its value in the same if-clause?

In CSH, is it possible to nest the test for an existance of a variable with the test for its value in the same if-clause?

#!/bin/csh

# This seems to work...
if ( $?VAR ) then
    echo "VAR exists"        
    if ( $VAR == true ) th开发者_运维问答en
        echo "VAR is true"
    endif
endif

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


Short-circuit evaluation is one of the many things that C shell doesn't do. You will have to use nested if statements or switch shells.

0

精彩评论

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