csh pleasures

Tom Christiansen tchrist at convex.COM
Fri Feb 8 05:13:37 AEST 1991


>From the keyboard of tve at 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 at kramden.acf.nyu.edu; echo "/From: $U/h:j" >>~/News/KILL; expire -f $U



More information about the Comp.unix.shell mailing list