bug-bash
[Top][All Lists]
Advanced

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

Re: "echo $((0x))" is accepted, treated as 0x0


From: Chet Ramey
Subject: Re: "echo $((0x))" is accepted, treated as 0x0
Date: Mon, 26 Jan 2026 12:53:17 -0500
User-agent: Mozilla Thunderbird

On 1/24/26 4:23 AM, Martin D Kealey wrote:
On Sat, 24 Jan 2026 at 12:10, Denys Vlasenko <dvlasenk@redhat.com> wrote:

Subject: "echo $((0x))" is accepted, treated as 0x0
The subject says it all.


Working as intended and as documented.

Intended, yes, as a longtime extension. Documented as such, not so much.

This is so that "echo $((0x$foo))" works as intended when foo contains only
hexadecimal digits. Note that the empty string complies with that
requirement.

This is not a particularly strong argument. If there's a concern that $foo
might be empty, there are easy workarounds.

--
``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/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

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