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: Martin D Kealey
Subject: Re: $((expr)) allows the hexadecimal constant "0x"
Date: Fri, 30 Jun 2023 03:28:36 +1000

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?


> 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.

-- 
-Martin


reply via email to

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