[PATCH] shell: fix $(()) precedence bug in "X=A?B:C" (it is _not_ "(X=A)?..)"
Denys Vlasenko
vda.linux at googlemail.com
Tue Aug 30 15:15:23 UTC 2022
Your patches seem to be against dash, not busybox git tree?
On Thu, Aug 11, 2022 at 6:16 PM Steffen Nurpmeso <steffen at sdaoden.eu> wrote:
>
>
> ---
> It was a one line fix. Five more tests
>
> +s I1=5 I2=10 I3=20;p "<$((I1-=5,1?I2:I3))>";e "<$I1><$I2><$I3>"
> +s I1=5 Ix=6 I2=10 I3=20;p "<$((I1=Ix,1?I2:I3))>";e "<$I1><$I2><$I3>"
> +s I1=5 Ix=6 I2=10 I3=20;p "<$((I1=Ix?I2:I3))>";e "<$I1><$I2><$I3>"
> +s I1=5 Ix=6 I2=10 I3=20;p "<$((I1*=Ix?I2:I3))>";e "<$I1><$I2><$I3>"
> +s I1=5 Ix=6 I2=10 I3=20;p "<$((0,I1*=Ix?I2:I3))>";e "<$I1><$I2><$I3>"
> +s I1=5 Ix=6 I2=10 I3=20;p "<$((I1*=Ix?I2:I3,Ix=21,I1*=Ix?I2:I3))>";e "<$I1><$I2><$I3>"
>
> I hope i am out now. Sorry for all the noise.
>
> shell/shexp-arith.h | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/shell/shexp-arith.h b/shell/shexp-arith.h
> index 17582f7d49..f48ada1b46 100644
> --- a/shell/shexp-arith.h
> +++ b/shell/shexp-arith.h
> @@ -584,8 +584,7 @@ junapre:
> op |= x;
>
> /* Resolve as much as possible */
> - while(lprec > a_SHEXP_ARITH_PREC_PAREN_LEFT &&
> - lprec != a_SHEXP_ARITH_PREC_COND){
> + while(lprec > a_SHEXP_ARITH_PREC_COND){
> if(!a_shexp__arith_op_apply(self))
> goto jleave;
> lop = *--sasp->sas_ops_top & a_SHEXP_ARITH_OP_MASK;
> --
> 2.37.1
>
>
> --steffen
> |
> |Der Kragenbaer, The moon bear,
> |der holt sich munter he cheerfully and one by one
> |einen nach dem anderen runter wa.ks himself off
> |(By Robert Gernhardt)
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
More information about the busybox
mailing list