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: Denys Vlasenko
Subject: Re: "echo $((0x))" is accepted, treated as 0x0
Date: Sat, 24 Jan 2026 14:23:12 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0



On 1/24/26 10:23, 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.

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.

Got it.

$ digits=''; echo $((0x$digits))
0

But why it's different for

$ digits=''; echo $((16#$digits))
bash: 16#: invalid integer constant (error token is "16#")




reply via email to

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