allbery@ncoast.UUCP (Brandon Allbery) (04/01/86)
Expires: Quoted from <678@nbires.UUCP> ["Re: C-Shell weirdness (count of words in a variable)"], by nose@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@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!''