Running the following script yields the error "X11: Undefined variable," whereas it should exit normally. ----------------------------------------------------- #!/bin/tcsh unsetenv X11 if ($?X11 && ($X11 == "huh?")) then echo "a" endif echo "b" -----------------------------------------------------
This bug is still present in tcsh-6.09-1.
This is not a bug, is it? Variable expansion takes place in one step for a complete line, before any evaluation of the expression or execution of command. As far as I'm aware, it has always been necessary to do if ($?X11) then if ($X11 == "huh?") then echo "a" endif endif to achieve the desired effect. Both in tcsh and in the original csh.
OK, it's a feature then.
The reported behavior is surprising but correct. Read "Csh Programming Considered Harmful", section 6 (Expression Evaluation). <http://www.perl.com/pub/a/language/versus/csh.html>