tags:

views:

16

answers:

1

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 ) 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  A: 

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.

Dennis Williamson

related questions