bug-bash
[Top][All Lists]
Advanced

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

Re: Arithmetic expression: recursive VAR evaluation suppresses desired V


From: Koichi Murase
Subject: Re: Arithmetic expression: recursive VAR evaluation suppresses desired VAR assignment
Date: Thu, 11 Aug 2022 10:14:41 +0900

2022年8月11日(木) 9:01 Steffen Nurpmeso <steffen@sdaoden.eu>:
>   #?0|kent:tmp$ /x/src/busybox.git/busybox sh xxx.sh
>   <6><0><6><I2+=1>
>   <1><1><5><I2+=1>

It seems your busybox interprets« I1=0?I1:I3 » as « (I1=0)?I1:I3 »,
but this violates POSIX XCU 2.6.4 and XCU 1.1.2. Also, the above
behavior doesn't seem to be reproduced by recent versions of busybox.
I have tried 1.23.2, 1.35.0, and 1.36.0 (master 7c2a3bd), but all
produce the following result:

<6><6><6><I2+=1>
<10><10><6><I2+=1>

Which version of busybox do you use?

$ busybox | head -1

The behavior of recent versions of busybox is still broken. The third
number in the second line is 6, which implies that busybox evaluates
the discarded branch of the conditional operator (i.e., expr3 of
true?expr2:expr3). This doesn't happen in any other shells that
support the recursive arithmetic evaluation. I tried bash, ksh93,
mksh, zsh, posh, and osh, but all produced the same result as bash
while yash, ash, and dash do not support the recursive arithmetic
evaluation.

> I think the busybox variant is correct.

I think both your version and recent versions of busybox sh are broken.

--
Koichi



reply via email to

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