Xref: utzoo comp.unix.wizards:24007 comp.unix.shell:1425 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!texsun!convex!usenet From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.unix.wizards,comp.unix.shell Subject: Re: csh pleasures Message-ID: <1991Feb07.181337.28425@convex.com> Date: 7 Feb 91 18:13:37 GMT References: <10880@pasteur.Berkeley.EDU> Sender: usenet@convex.com (news access account) Reply-To: tchrist@convex.COM (Tom Christiansen) Followup-To: comp.unix.shell Organization: CONVEX Software Development, Richardson, TX Lines: 30 Nntp-Posting-Host: pixel.convex.com From the keyboard of tve@sprite.berkeley.edu (Thorsten von Eicken): :Question: what does the following c-shell script print out? :Anybody care defending? : : #!/bin/csh -f : set a=0 : set b=1 : if($a) then : if($b) then : echo one : else : echo two : endif : else : echo three : endif On my system it prints out "three", because we fixed it. On many systems, it prints out "two". The reason is that the csh misparses "if(". The only defense is for to stop people from writing ugly code with parens next to their if's and while's. More seriously, there is no defense for the csh. Just say no. Trust me -- you'll be glad you did so in the long run. --tom -- "Still waiting to read alt.fan.dan-bernstein using DBWM, Dan's own AI window manager, which argues with you for 10 weeks before resizing your window." ### And now for the question of the month: How do you spell relief? Answer: U=brnstnd@kramden.acf.nyu.edu; echo "/From: $U/h:j" >>~/News/KILL; expire -f $U