about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--Src/loop.c7
2 files changed, 5 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index fef3a92c9..629d36a7b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2016-11-05  Barton E. Schaefer  <schaefer@zsh.org>
 
+	* 39844: Src/loop.c: fix "while" condition as per 39839
+
 	* 39839: Src/loop.c: fix "return" from "if" condition
 
 	* 39838: Src/builtin.c: another missing unqueue_signals()
diff --git a/Src/loop.c b/Src/loop.c
index f65c72bf4..367c0df5c 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -439,13 +439,12 @@ execwhile(Estate state, UNUSED(int do_exec))
             if (!((lastval == 0) ^ isuntil)) {
                 if (breaks)
                     breaks--;
-                lastval = oldval;
+		if (!retflag)
+		    lastval = oldval;
                 break;
             }
-            if (retflag) {
-                lastval = oldval;
+            if (retflag)
                 break;
-            }
 
 	    /* In case the loop body is also a functional no-op,
 	     * make sure signal handlers recognize ^C as above. */