Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG] program flow corruption involving dot script and 'until' loop
- X-seq: zsh-workers 44271
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [BUG] program flow corruption involving dot script and 'until' loop
- Date: Fri, 03 May 2019 20:09:40 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ntlworld.com; s=meg.feb2017; t=1556910580; bh=hPIglMHkjC0qRBnKEAwIZmUpnUnEC2GtmWxsnrLXzqw=; h=Subject:From:To:Date:In-Reply-To:References; b=SXE/59nkzq9XRpgr/UxRxo8+0ITvdul3xUdxYb2VPcdx4Y9YpPohfcbq/+W5I2rgO XBcR15zZaLYqp2EjdCFqoL+Bzh3RZJJgB+oEs6jMwcT6w5BMw7VNBf1foKV5sQGg76 r+9kY8STxGLIkZyM0ddTWssa+qg3s4tZVX0f5pbFsAEunEWvYgDw1bjXK/myL1zxVk aIH6byvMeHdvQKbR+aL2ZC0gh+qaM3B75Zyy1PCqOchoBoisNRTgMho3OfJo3OP38Q LdhVcoS5JaPf0/2K2wtDYm6OjHn8MJ94Mdc5HU1AeYh0qn3TlqJnAOA5EqgRFCXqd8 J3GSjtISJBftA==
- In-reply-to: <bc4ab83e-2eb0-6737-1f2c-3530e508b68c@inlv.org>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <bc4ab83e-2eb0-6737-1f2c-3530e508b68c@inlv.org>
On Fri, 2019-05-03 at 18:20 +0100, Martijn Dekker wrote:
> Looks like the 'return' in the dot script causes zsh to just give up on
> the program altogether.
diff --git a/Src/loop.c b/Src/loop.c
index 1013aeb50..3fa7006aa 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -425,7 +425,7 @@ execwhile(Estate state, UNUSED(int do_exec))
breaks--;
simple_pline = old_simple_pline;
- } else
+ } else {
for (;;) {
state->pc = loop;
noerrexit = NOERREXIT_EXIT | NOERREXIT_RETURN;
@@ -445,8 +445,11 @@ execwhile(Estate state, UNUSED(int do_exec))
lastval = oldval;
break;
}
- if (retflag)
+ if (retflag) {
+ if (breaks)
+ breaks--;
break;
+ }
/* In case the loop body is also a functional no-op,
* make sure signal handlers recognize ^C as above. */
@@ -470,6 +473,7 @@ execwhile(Estate state, UNUSED(int do_exec))
freeheap();
oldval = lastval;
}
+ }
cmdpop();
popheap();
loops--;
diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst
index 339ce7494..1ed3cb6b7 100644
--- a/Test/A01grammar.ztst
+++ b/Test/A01grammar.ztst
@@ -640,6 +640,16 @@
>1
>0
+ echo 'echo dot
+ until return 42; do
+ :
+ done' >until_dot
+ . ./until_dot
+ echo After dot
+0:return in positive until test in dot file does not cause excess breaks
+>dot
+>After dot
+
echo 'echo $?' >dot_status
false
. ./dot_status
Messages sorted by:
Reverse Date,
Date,
Thread,
Author