Re: "echo $((0x))" is accepted, treated as 0x0
Denys Vlasenko <[email protected]>
| Newsgroups | gmane.comp.shells.bash.bugs |
|---|---|
| Message-ID | <[email protected]> |
On 1/24/26 10:23, Martin D Kealey wrote: > On Sat, 24 Jan 2026 at 12:10, Denys Vlasenko <[email protected]> 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#")