csh pleasures

Vadim Antonov avg at hq.demos.su
Sat Feb 9 03:09:01 AEST 1991


In <10880 at pasteur.Berkeley.EDU> tve at sprite.berkeley.edu (Thorsten von Eicken) writes:

>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                             <<<<<< look at here. avg.
>               if($b) then                     <<<<<<
>			echo one
>		else
>			echo two
>		endif
>	else
>		echo three
>	endif

>Thorsten von Eicken - tve at sprite.berkeley.edu

It's the long lived bug in C-shell's parser - I've fixed it a couple
of years ago in the revision of C-shell for DEMOS systems.
The simpliest way to avoid this bug is to put spaces before and after ().

(After fixing this bug I still always put extra spaces - someone
could call it "a cargo-cult programming" :-).

Vadim Antonov
DEMOS, Moscow, USSR

ObBug :-)

Older versions of C-shell had && and || exchanged - to the extra fun of
novices!



More information about the Comp.unix.internals mailing list