When is an expression "true"?
Peter Steele
peter at aucs.AcadiaU.ca
Thu May 9 03:33:42 AEST 1991
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 at acadiau.ca Tel: 902-542-2201
Software Analyst, Acadia University, Wolfville, NS Fax: 902-542-7224
More information about the Comp.unix.shell
mailing list