Nick Stoughton wrote:
> We do not have to treat "asdf" as a decimal integer, and the standard is
> silent as to what we do have to treat it as. So, our primary intent
> yesterday, to permit a shell to try variable substitution as an
> extension, still stands. If $asdf has a numeric value, it must be a
> decimal numeric value. An implementation could fail with a "bad number"
> diagnostic for
> $ asdf=1
> $ test asdf -ge 0
Except we have seen a 16 year old implementation of shells
(Bourne and Korn) that do a variable substitution _then_
an arithmetic evaluation on the numeric values before running
the test. How many folks take advantage of that? :)
> or it could succeed (setting $? to 0, since 1 is > 0)
> Portable applications should not use such constructs, but
> implementations may provide support if they want to.
On AIX 5.1, the Bourne shell does not do either the variable
substitution or the arithmetic eval, though its ksh (Version M-11/16/88f)
works that way.
> But we do still need a "the standard is silent" interp for the basic
> question.
>
> $ test 0.1 -eq 1e-1
> should always fail (they aren't decimal numbers);
(they aren't decimal _expressions_)
> $ test asdf -ge 0
> might succeed.
|