Subject: Interesting problem with csh shell script??
To: None <help@adsl-216-103-105-65.dsl.snfc21.pacbell.net>
From: None <refling@stanfordalumni.org>
List: netbsd-help
Date: 05/26/2003 23:15:11
Can someone point out what is going on with the following csh shell
script?

# cat 1
#!/bin/csh -f 

if { false } then
    echo START OF FALSE
    if { true } then > /dev/null
        echo TRUE BLOCK
    endif
    echo CANNOT BE HERE
else
    echo ELSE
endif

# ./1
CANNOT BE HERE



To my way of thinking, it should print out ELSE but does not.  If the
"> /dev/null" is placed in the { } block, then it works as expected, as
below...  How can changing the location of the redirection alter the
nesting of the blocks???  csh and tcsh both do the same.


# cat 2
#!/bin/csh -f 

if { false } then
    echo START OF FALSE
    if { true > /dev/null } then
        echo TRUE BLOCK
    endif
    echo CANNOT BE HERE
else
    echo ELSE
endif


# ./2
ELSE