Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!sdd.hp.com!spool.mu.edu!news.cs.indiana.edu!nstn.ns.ca!aucs.acadiau.ca!peter From: peter@aucs.AcadiaU.ca (Peter Steele) Newsgroups: comp.unix.shell Subject: When is an expression "true"? Message-ID: <1991May8.173342.2514@aucs.AcadiaU.ca> Date: 8 May 91 17:33:42 GMT Article-I.D.: aucs.1991May8.173342.2514 Reply-To: peter@aucs.acadiau.ca (Peter Steele) Distribution: na Organization: School of Computer Science, Acadia Univ., Nova Scotia Lines: 26 I wrote a simple Cshell script the other day that looked something like this: set f=`ls` if $#f > 1 then ... endif In other words, I only wanted the if statement to be executed if there was more than one file in the directory. This did not work; it went ahead and did the body of the if statement even when there was only one file present. To file the problem, I added some brackets: if ($#f > 1) then ... Why are parentheses needed here? I know I've done other stuff that hasn't needed parentheses, e.g. if $status != 0 then ... What's the story? -- Peter Steele Postmaster peter.steele@acadiau.ca Tel: 902-542-2201 Software Analyst, Acadia University, Wolfville, NS Fax: 902-542-7224