On 2011-01-15 08.29, Philip Guenther wrote:
On Fri, Jan 14, 2011 at 10:39 PM, Philip Guenther<[email protected]>  wrote:
On Fri, Jan 14, 2011 at 8:11 PM, Benny Lofgren<[email protected]>  wrote:
+ Makes it able to use C-style radix prefixes to integers in order to do
calculations in octal and hexadecimal.
...
Unfortunately, this would make expr violate POSIX.

I should note that this would be legal behavior if a non-POSIX option
was used.  For example, it would be legal to behave like this if any
of your proposed -c, -o, -x, or -X options were used.

I've noted the POSIX objections in your previous mail, and yes, that would invalidate my addition.

I could theoretically add a '-d' option to the suite above, to a) force "my" behaviour and b) (redundantly) specify "decimal" output.

But I'm still somewhat concerned about the introduction of switches to expr (where there are none at all today) actually breaking working shell scripts so I suppose those additions are better left out altogether.

(Maybe I'm overly cautious, but I'm thinking along the lines of:

    ARGS='-c'
    expr ${ARGS} : '-[coXx]' # Check for valid options

Although I don't know if this would be a use case actually encountered in the wild.)

And, as noted elsewhere, there ARE other ways of doing base conversions, but that isn't the only use I would see for this. I think it would actually be convenient to be able to do hexadecimal calculations in a shell script (although it would admittedly not be very portable...).

Oh well, I won't argue this too much, just thought I would toss in the idea. However, the 64-bit stuff is an actual concern I've had, so that one I'll defend harder. :-)

Thanks for the input.


/Benny

--
internetlabbet.se     / work:   +46 8 551 124 80      / "Words must
Benny Lvfgren        /  mobile: +46 70 718 11 90     /   be weighed,
                    /   fax:    +46 8 551 124 89    /    not counted."
                   /    email:  benny -at- internetlabbet.se

Reply via email to