More C-shell weirdness [Another word count problem]

John Pierce jwp at sdchem.UUCP
Thu Apr 3 17:51:49 AEST 1986


In article <684 at nbires.UUCP> nose at nbires.UUCP (Steve Dunn) writes:

	> set a = ''
	> set a = ($a '')	 set a = ('' '')
	> echo $#a		 echo $#a
	> 
	> Yields 1		 Yields 2

and asks for an explanation....  In the first case $a is expanded to a null
string before the assignment is done, and, therefore, isn't seen as a string
at the time the assignment is made; there is no such thing as an unquoted
null string (this is implied, though not stated explicitly in exactly those
words by csh(1), page 1, "Lexical Structure").  Note that

	set a = ''
	set a = ( "$a" '' )
	echo $#a

yields 2 since the null string that is $a is quoted and is, therefore, a word.

				John Pierce, Chemistry, UC San Diego
				jwp%chem at ucsd.edu
				sdcsvax!sdchem!jwp



More information about the Comp.unix.wizards mailing list