Xref: utzoo comp.bugs.4bsd:1326 comp.unix.wizards:17202 Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!wugate!wuphys!marty From: marty@wuphys.UUCP (Marty Olevitch) Newsgroups: comp.bugs.4bsd,comp.unix.wizards Subject: csh problem involving nested ifs? Keywords: csh, bug, nested if Message-ID: <685@wuphys.UUCP> Date: 10 Jul 89 16:02:05 GMT Organization: Washington U Physics, St. Louis Lines: 56 It appears that csh does not correctly handle nested if-then-else statements. The following script illustrates the problem, which appears in versions of csh on MORE/bsd (mt Xinu 4.3), SunOS 3.1, SunOS 4.0, and Ultrix 2.0. Am I missing some bug in this script? If not, it looks like a bug in csh (an equivalent sh program works fine). #! /bin/csh set v1 = $1 set v2 = $2 echo "v1 = $v1 and v2 = $v2" if($v1 == 1) then echo checkpoint 1 if($v2 == 1) then echo 11 else echo 12 endif echo checkpoint 2 else echo checkpoint 3 if($v2 == 1) then echo 21 else echo 22 endif echo checkpoint 4 endif Here is a little chart showing the command lines issued, the expected results, and the actual results. command line expect get ------------ ------ ------- iftest 1 1 checkpoint 1 checkpoint 1 11 11 checkpoint 2 checkpoint 2 checkpoint 4 iftest 1 2 checkpoint 1 checkpoint 1 12 12 checkpoint 2 checkpoint 2 checkpoint 4 iftest 2 1 checkpoint 3 12 21 checkpoint 2 checkpoint 4 checkpoint 4 iftest 2 2 checkpoint 3 12 22 checkpoint 2 checkpoint 4 checkpoint 4 Marty Olevitch Internet: marty@wuphys.wustl.edu Washington University UUCP: uunet!wugate!wuphys!marty Physics Department, Campus Box 1105 Bitnet: marty@wuphys.WUSTL St Louis MO 63130 USA Tel: (314) 889-6285