From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: [BUG] program flow corruption involving dot script and 'until' loop
Date: Fri, 03 May 2019 20:09:40 +0100 [thread overview]
Message-ID: <c42eeee8eb6464d41eb4db20e81727177ec1b370.camel@ntlworld.com> (raw)
In-Reply-To: <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
prev parent reply other threads:[~2019-05-03 19:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-03 17:20 Martijn Dekker
2019-05-03 18:08 ` Mikael Magnusson
2019-05-03 19:09 ` Peter Stephenson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c42eeee8eb6464d41eb4db20e81727177ec1b370.camel@ntlworld.com \
--to=p.w.stephenson@ntlworld.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).