Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!eagle!harpo!seismo!hao!hplabs!sri-unix!lcc.bob@ucla-locus From: lcc.bob%ucla-locus@sri-unix.UUCP Newsgroups: net.unix-wizards Subject: csh if..else..if...endif...endif bug Message-ID: <17140@sri-arpa.UUCP> Date: Fri, 2-Mar-84 12:47:30 EST Article-I.D.: sri-arpa.17140 Posted: Fri Mar 2 12:47:30 1984 Date-Received: Mon, 5-Mar-84 01:10:12 EST Lines: 58 From: Bob EnglishThe 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.