Paul Eggert wrote:
> Bob Proulx writes:
> > However, I can't see anywhere that expr is defined to always read
> > integers as decimal values.
>
> The current documentation says under "expr invocation"
>
> Operands are either integers or strings. Integers consist of one or
> more decimal digits, with an optional leading @samp{-}.
>
> So yes, they're always decimal. (POSIX requires this.)
I don't (yet) follow that reasoning. Note that I don't want to change
the behavior of expr. I am only pursuing the understanding of the
standard for expr.
The SUSv3 says the following:
integer
An argument consisting only of an (optional) unary minus followed by
digits.
Neither that nor the info documentation says anything about a base for
the integer constants. Since it is not specified why couldn't it use
the C rules the same as printf does?
printf "%d\n" 010
8
For printf that is the correct result because printf is defined to be
evaluated as a C constant as described by the ISO C standard. Why
couldn't expr use the same interpretation of integer constants?
expr 010
8
Why wouldn't the this form above be conforming? The integer consists
only of digits. I can read nothing that says that is not an allowed
behavior. Is there some catch-all in the SUS docs which say that
integers must be decimal? Why can't integers be octal?
Bob
_______________________________________________
Bug-coreutils mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/bug-coreutils