Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 alpha 5/22/85; site cbrma.UUCP Path: utzoo!watmath!clyde!cbosgd!cbuxc!cbuxb!cbrma!karl From: karl@cbrma.UUCP (Karl Kleinpaste) Newsgroups: net.unix-wizards Subject: Re: More C-shell weirdness [Another word count problem] Message-ID: <4366@cbrma.UUCP> Date: Thu, 3-Apr-86 11:30:33 EST Article-I.D.: cbrma.4366 Posted: Thu Apr 3 11:30:33 1986 Date-Received: Sat, 5-Apr-86 07:41:34 EST References: <684@nbires.UUCP> Distribution: net Organization: AT&T-BL, RMAS, Columbus Lines: 35 Keywords: order of substitutions In article <684@nbires.UUCP> nose@nbires.UUCP (Steve Dunn) writes: >This: >set a = '' >set a = ($a '') >echo $#a >Yields 1 > >But this: > >set a = ('' '') >echo $#a >Yields 2 > >This curious behavior has not actually caused me any trouble but I >am a bit puzzled It's because of the order in which things are being substituted in the input line. That is, what is happening is that set a = ($a '') becomes set a = ( '') when $a's empty value is stuffed into the line. Then the interpretation of the remainder gives `a' the single value ''. As a counterpoint, try set a = '' set a = ("$a" '') echo $#a which yields 2. The reason is that you've stipulated extra quotings, which preserve values for longer than the simple replacement of $a in the input line with its null value. The use of double quotes causes $a to be interpreted within them, subsituting its null string, while leaving that null string quoted, so that two null strings result. -- Karl Kleinpaste