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: Andreas Kähäri
Subject: Re: "echo $((0x))" is accepted, treated as 0x0
Date: Sat, 24 Jan 2026 18:57:35 +0100

On Sat, Jan 24, 2026 at 11:13:37PM +0700, Robert Elz wrote:
>     Date:        Sat, 24 Jan 2026 09:24:20 +0100
>     From:        Andreas =?utf-8?B?S8OkaMOkcmk=?= <andreas.kahari@abc.se>
>     Message-ID:  <aXSBtKkWn1bnOmAb@dolores.invalid>
> 
>   | On Sat, Jan 24, 2026 at 03:10:28AM +0100, Denys Vlasenko wrote:
>   | > The subject says it all.
> 
>   | And $(()) is expanded to 0.  What would you suggest would happen?
> 
> At least in posix mode, both should be rejected as errors.   Since they
> are errors, neither 0x nor "" (I mean nothing) is a valid C expression,
> it is not necessarily invalid for a shell to allow them as extensions.
> But they are extensions, and in posix mode really should be rejected,
> so application writers can better test their scripts for better portabillity.
> 
> kre

Well, it's at least consistent with

        $ declare -i v=
        $ echo $v
        0

-- 
Matti Andreas Kähäri
Uppsala, Sweden

.



reply via email to

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