Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!whuxl!whuxlm!akgua!gatech!seismo!rlgvax!hadron!jsdy From: jsdy@hadron.UUCP Newsgroups: net.unix-wizards Subject: Re: More C-shell weirdness [Another word count problem] Message-ID: <355@hadron.UUCP> Date: Thu, 3-Apr-86 01:36:16 EST Article-I.D.: hadron.355 Posted: Thu Apr 3 01:36:16 1986 Date-Received: Sat, 5-Apr-86 12:21:49 EST References: <684@nbires.UUCP> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Distribution: net Organization: Hadron, Inc., Fairfax, VA Lines: 39 Summary: Use "$a" wherever possible. In article <684@nbires.UUCP> nose@nbires.UUCP (Steve Dunn) writes: >set a = '' >set a = ($a '') >echo $#a > >Yields 1 > >set a = ('' '') >echo $#a > >Yields 2 set a = '' set a = ("$a" '') echo $#a 2 Note that $a, where a is empty or containing all manner of white space, gets fed back into the parser just as it appears: as no characters or white space. To be taken seriously, it must appear in double quotes (which does sometimes cause problems). Consider: if ($a == "") ... if ("" == "$a") ... I use the latter form, partly because $a might be -x or something (!). The former form could all too easily turn into if ( == "") if what you r e a l l y wanted to test was true. Testing this, I am enthralled to find that if ( == "") and even if ( == ) both test out true in csh!!! I guess this is because of the parsing that occurs at different times, as I mentioned in another letter. This gives a syntax error in any sh that I've ever used: Thompson, Mashey, Bourne, or Korn. -- Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}