tchrist@convex.COM (Tom Christiansen) (02/08/91)
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
guy@auspex.auspex.com (Guy Harris) (02/10/91)
>Older versions of C-shell had && and || exchanged - to the extra fun of >novices! And that loser version (as I remember, the bug was basically that the author forgot that an exit status of 0 means "true" and a non-zero exit status means "false") made it into Xenix, from what I've heard, which prolonged its life far beyond what it should have been - that version ended up being the C shell shipped with S5R3.2. S5R4 has a C shell based on the SunOS 4.1 one, which is in turn based on the 4.3BSD one, so that bug is fixed.