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

Chet Ramey <[email protected]>
Newsgroups gmane.comp.shells.bash.bugs
Organization ITS, Case Western Reserve University
Message-ID <[email protected]>
On 1/24/26 4:23 AM, 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.

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    [email protected]    http://tiswww.cwru.edu/~chet/
OpenPGP_signature.asc (application/pgp-signature, 203 B)
-----BEGIN PGP SIGNATURE-----

wmMEABEIACMWIQR8ATX7CIqvbGbGULm7WGnwZOp0qwUCaXeqDQUDAAAAAAAKCRC7WGnwZOp0qzEL
AJ9IlnHIx9TrY2lXE/DtNHr0MYAjuwCgoAvdqEw7olqhJgiDKfHzgxM0//A=
=9k7l
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.