bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: $((expr)) allows the hexadecimal constant "0x"


From: Chet Ramey
Subject: Re: $((expr)) allows the hexadecimal constant "0x"
Date: Thu, 29 Jun 2023 16:20:13 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.12.0

On 6/29/23 1:28 PM, Martin D Kealey wrote:
On Thu, 29 Jun 2023 at 19:45, Denys Vlasenko <dvlasenk@redhat.com> wrote:

IIRC bash used to allow numeric constants of the
BASE#DIGITS form even if the DIGITS part was empty.
IOW: not only "64#0", but "64#" too was accepted
as a valid zero constant.

This no longer works in 5.2.15, probably better than
former behavior, "64#" looked quite confusing.


Oh great :-(

This change will break scripts that use $((10#$somevar)) to cope with
somevar having leading zeroes OR BEING EMPTY.

Or containing a unary plus or minus, which was the start of the discussion
that led to this clearly invalid syntax changing in the first place. You
might be interested in the discussion:

https://lists.gnu.org/archive/html/bug-bash/2018-07/msg00015.html
https://lists.gnu.org/archive/html/bug-bash/2019-06/msg00039.html


Is there any chance this can be reversed before it becomes an official
release?

This happened years ago.



However, a somewhat similar situation with hex prefix,
0xDIGITS, still allows just "0x" as a valid zero constant.

Not sure whether this should be considered a bug,
and whether it's worth fixing - just letting you know.


No, definitely not. It's established behaviour, and should not be removed
without an explicit shopt.

It's clearly a bug -- it's an invalid C constant. I suppose we can call it
an extension.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]