[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: expr integer format always decimal?
From: |
Bob Proulx |
Subject: |
Re: expr integer format always decimal? |
Date: |
Fri, 10 Sep 2004 10:12:26 -0600 |
User-agent: |
Mutt/1.3.28i |
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
- expr integer format always decimal?, Bob Proulx, 2004/09/10
- Re: expr integer format always decimal?, Paul Eggert, 2004/09/10
- Re: expr integer format always decimal?,
Bob Proulx <=
- Re: expr integer format always decimal?, Paul Eggert, 2004/09/10
- Re: expr integer format always decimal?, Bob Proulx, 2004/09/11
- Re: expr integer format always decimal?, Andreas Schwab, 2004/09/11
- Re: expr integer format always decimal?, Bob Proulx, 2004/09/11
- Re: expr integer format always decimal?, Andreas Schwab, 2004/09/12
- Re: expr integer format always decimal?, Paul Eggert, 2004/09/11