I think I’ve got it. Needs testing though ;)
There’s also other fixes, like ((foo) || bar) works now,
but this one applies to this Debian PR.


Commit ID:      1004AC8A0EC1AB8E5E0
CVSROOT:        /cvs
Module name:    src
Changes by:     t...@herc.mirbsd.org    2009/10/04 13:19:35 UTC

Modified files:
        bin/mksh       : check.t expr.c sh.h

Log message:
fix lazy evaluation of assignments in ternary ops

Index: src/bin/mksh/check.t
diff -up src/bin/mksh/check.t:1.318 src/bin/mksh/check.t:1.319
--- src/bin/mksh/check.t:1.318  Sun Oct  4 12:45:21 2009
+++ src/bin/mksh/check.t        Sun Oct  4 13:19:32 2009
@@ -224,7 +224,6 @@ name: arith-lazy-3
 description:
        Check that assignments not done on non-evaluated side of ternary
        operator and this construct is parsed correctly (Debian #445651)
-expected-fail: yes
 stdin:
        x=4
        y=$((0 ? x=1 : 2))
Index: src/bin/mksh/expr.c
diff -up src/bin/mksh/expr.c:1.36 src/bin/mksh/expr.c:1.37
--- src/bin/mksh/expr.c:1.36    Sat Sep 26 04:01:32 2009
+++ src/bin/mksh/expr.c Sun Oct  4 13:19:33 2009
@@ -465,10 +465,12 @@ evalexpr(Expr_state *es, int prec)
                }
                if (IS_ASSIGNOP(op)) {
                        stvui(vr, res);
-                       if (vasn->flag & INTEGER)
-                               setint_v(vasn, vr, es->arith);
-                       else
-                               setint(vasn, res);
+                       if (!es->noassign) {
+                               if (vasn->flag & INTEGER)
+                                       setint_v(vasn, vr, es->arith);
+                               else
+                                       setint(vasn, res);
+                       }
                        vl = vr;
                } else if (op != O_TERN)
                        stvui(vl, res);



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to