Paul Eggert wrote: > Bob Proulx writes: > > integer > > An argument consisting only of an (optional) unary minus followed by > > digits. > > It also says, for example: > expr1 + expr2 Addition of decimal integer-valued arguments.
Hmm... Yes, but it could also be read that only decimal integer-valued arguments have defined behavior and that any non-decimal integer-valued arguments have undefined behavior. Note that I am not trying to change the behavior of expr but only to understand what the standard allows for its behavior. > So, under your interpretation, "expr 010" would print 8, but "expr 010 > + 0" would print 10? That doesn't sound right to me. My question was why couldn't a conforming implementation interpret 010 as octal and therefore print a decimal 8? You are trying to say that if the operators are used then all arguments are decimal. And from the passage you quoted I can see that position. I don't think that is worded strongly enough however. [In the hypothetical case of 010 being octal, which does not exist and is not desired by me, the above 'expr 010 + 0', if 010 is octal, would still print 8. However since that operation is not defined by the standard as per your pointing out that that it says specifically that operations occur on decimal arguments, the operation would be undefined behavior. Again this is hypothetical. Let's not implement it that way!] > > 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? > > Even if you're right that POSIX allows "expr 08" to fail (which I > doubt), GNU expr would still disagree with all the other > implementations out there. I don't think the incompatibility hassles > would be worth it. I am sorry but I don't understand your statement. You are making the assumption that because the standard has a hole in it that GNU expr *must* change its behavior to tickle that hole? (No I am sure that is not what you are saying but it does read like it.) GNU expr agrees with all of the other implementations out there. All of them read arguments as being decimal integer constants. As I have said in each message I am NOT proposing a change in expr behavior but only seeking a clarification of the standard for the behavior of expr. I think it is a hole in the standard, as you later suggest. > There are lots of places where POSIX is inconsistent: sometimes it > requires that 010 be treated as 8, sometimes not. It's a mess, but > fixing it would require changing POSIX, not an easy task and one that > I'm not sure is worth it. Plus, how many old scripts would you break? How can clarifying the standard to more strongly say that arguments are interpreted as decimal integer constants break scripts? In any case, I am happy with the result of the discussion. If I feel motivated beyond this I will pursue a clarification with the standards committees. Thank you for your input! Bob _______________________________________________ Bug-coreutils mailing list [EMAIL PROTECTED] http://lists.gnu.org/mailman/listinfo/bug-coreutils
