csh variables

Brandon Allbery allbery at ncoast.UUCP
Tue Apr 1 10:43:08 AEST 1986


Expires:

Quoted from <678 at nbires.UUCP> ["Re: C-Shell weirdness (count of words in a variable)"], by nose at nbires.UUCP (Steve Dunn)...
+---------------
| > 
| > > 2: Count of number of words in a variable (Or when is nothing something)
| > > 
| > > This:
| > > 
| > > set hosed = ''
| > > echo $#hosed
| > > 
| > > yields the result '1'
| > 
| >   But of course! The variable has one value: a null string. And, if you do
| > 
| > set hosed=( '' junk)
| > 
| > then what do you suppose $#hosed is? If you got 2, drink a potion of raise
| > level and read on! :-) If you do
+---------------

I had a flash of insight one day after trying unsuccessfully to figure this
out; think of it not as Bourne shell variables, but as an obscure dialect of
LISP.  If '' is T and () is NIL then the behavior of

	set foo

versus

	set foo = ()

is reasonable.  It also explains the word business reasonably.  (I'm thinking
specifically of a very limited LISP I ran into once; I don't remember which
one, but it had never heard of dotted pairs  Maybe it was based on csh :-)

--Brandon
-- 
decvax!cwruecmp!ncoast!allbery  ncoast!allbery at Case.CSNET  ncoast!tdi2!brandon
(ncoast!tdi2!root for business) 6615 Center St. #A1-105, Mentor, OH 44060-4101
Phone: +01 216 974 9210      CIS 74106,1032      MCI MAIL BALLBERY (part-time)
	   ``You're being logical -- a most unfair way to argue!''



More information about the Comp.unix.wizards mailing list