lcc.bob%ucla-locus@sri-unix.UUCP (03/02/84)
From: Bob English <lcc.bob@ucla-locus>
The bug is simple: you can't (read CAN NOT) put an if...endif
inside the "else" clause in "csh". White space has nothing to do
with it. Other commands have nothing to do with it. It simply
doesn't work correctly. Try this script, for instance:
#! /bin/csh
set x=1
if($x == 1) then
set y=2
else
echo hello there
if($y == 2) then
echo "line 1"
else
echo "line 2"
endif
echo "shouldn't get here"
endif
echo "finished"
Even with a command before and after the nested "if", "shouldn't
get here" is printed. In fact, you can put ANYTHING you want
between the else and the endif, csh will ignore it. Fo example,
try:
#! /bin/csh
set x=1
if($x == 1) then
set y=2
else
if
while
switch
foreach
echo hello there
if($y == 2) then
echo "line 1"
else
echo "line 2"
endif
echo "shouldn't get here"
endif
echo "finished"
I don't know about other flow-control constructions, but when
"csh" ignores shell commands because of an "else", it ignores
everything up to and including the next endif. I don't
particularly like this feature, but that's the way it works.
Program around it or use a different shell.
--bob--
P.S. I don't particularly like "csh", but I do like job-control,
history, and aliasing, none of which are relevant to shell
programming, since "csh" can't seem to handle them when it's not
interactive.ss@wivax.UUCP (Sid Shapiro) (03/07/84)
How can you say that white space doesn't matter??? Put the damn white space in and it DOES matter. Sheesh! Without white space you get the "shouldn't get here" message. With the white space you don't get that line.