---
I found the hopefully last problem.  It is a mystery how _that_
miss was not caused by any of the tests yet; only because of
busybox different stack pattern it was catched at all!
The three new tests

  s I1=I2=0 I2=5 I3=I2+=1;p "<$((I1?I1:I3))>";e "<$I1><$I2><$I3>"
  s I1=I1=10 I2=5 I3=I2+=1;p "<$((I1=0?I1:I3))>";e "<$I1><$I2><$I3>"
  s I1=I1=10 I2=5 I3=I2+=1;p "<$((I1=1?I1:I3))>";e "<$I1><$I2><$I3>"

however would have catched it.
Interestingly we now have a divergence to the bash $(())
implementation, and i have opened a bash bug report because of it,
as i think we are correct: given this file

  # make this work with (ba)sh \
  command -v shopt && shopt -s expand_aliases;\
  alias p=printf;alias e=echo;alias s=export
  s I1=I1=10 I2=5 I3=I2+=1;p "<$((I1=0?I1:I3))>";e "<$I1><$I2><$I3>"
  s I1=I1=10 I2=5 I3=I2+=1;p "<$((I1=1?I1:I3))>";e "<$I1><$I2><$I3>"

we get

  -<6><6><6><I2+=1>
  -<10><10><5><I2+=1>
  +<6><0><6><I2+=1>
  +<1><1><5><I2+=1>

compared to bash, and i think the latter two are correct.
Hey!

May it now rest in peace, finally.
And sorry for all the noise!
I hope you like it, if you want to include it in busybox i would
be willing to embed it better, which surely nibbles quite a few
bytes off the thing.

Ciao from Germany.

 shell/shexp-arith.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/shell/shexp-arith.h b/shell/shexp-arith.h
index 4b23746df1..17582f7d49 100644
--- a/shell/shexp-arith.h
+++ b/shell/shexp-arith.h
@@ -593,7 +593,16 @@ junapre:
                   }
 
                   ASSERT(sasp->sas_nums_top > sasp->sas_nums);
-                  if((--sasp->sas_nums_top)->sav_val == 0)
+                  --sasp->sas_nums_top;
+
+                  if((op & a_SHEXP_ARITH_OP_MASK) != a_SHEXP_ARITH_OP_ASSIGN &&
+                        sasp->sas_nums_top->sav_var != NIL){
+                     if(!a_shexp__arith_val_eval(self, sasp->sas_nums_top))
+                        goto jleave;
+                     sasp->sas_nums_top->sav_var = NIL;
+                  }
+
+                  if((sasp->sas_nums_top)->sav_val == 0)
                      op |= a_SHEXP_ARITH_OP_FLAG_WHITEOUT;
 
                   op |= *sasp->sas_ops_top & a_SHEXP_ARITH_OP_FLAG_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@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to