[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: math. operation on empty variables
From: |
Chet Ramey |
Subject: |
Re: math. operation on empty variables |
Date: |
Mon, 26 Jul 2004 16:05:11 -0400 |
> >/usr/local/bin/bash test.sh
> test.sh: [: : integer expression expected
> force
>
> >/usr/local/bin/bash --posix test.sh
> test.sh: [: : integer expression expected
> force
>
> questions:
> - is there any reason for NOT substitute null values to 0 for integer
> expressions?
Because I don't believe it's the correct behavior for the arithmetic
comparison operators to `test'.
> - would be nice posix sh behave the same? (although posix does not =
> define a
> lot)
It's not really defined by posix. The korn shell and `posix' shells derived
from it perform arithmetic expansion on the operands of the arithmetic
operators, for instance, which posix says nothing about. (That's where the
the evaluation of "" as 0 comes from, by the way.)
> - why do we get the result force after errormsg?
Because the test command failed, and that branch of the `if' was taken.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
Live...Laugh...Love
Chet Ramey, ITS, CWRU chet@po.cwru.edu http://tiswww.tis.cwru.edu/~chet/