[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: $((expr)) allows the hexadecimal constant "0x"
From: |
Emanuele Torre |
Subject: |
Re: $((expr)) allows the hexadecimal constant "0x" |
Date: |
Thu, 29 Jun 2023 20:47:27 +0200 |
User-agent: |
Mutt/2.2.10 (2023-03-25) |
On Fri, Jun 30, 2023 at 03:28:36AM +1000, 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.
>
> (This is not a security risk as long as (1) the variables are
> sanity-checked to contain nothing but decimal digits (and logically an
> empty string satisfies that condition) or (2) the script runs as the user
> providing the value.)
>
> Is there any chance this can be reversed before it becomes an official
> release?
This regression has existed since bash 5.1, personally I have been using
$(( 10#0$var )) instead of $(( 10#$var )) for a while, so I didn't
even know 10# by itself used to be accepted before bash 5.1.
o/
emanuele6