From: Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
To: zsh-workers@sunsite.auc.dk (Zsh hackers list)
Subject: Re: For loop bug
Date: Sat, 14 Sep 2002 00:31:51 +0100 [thread overview]
Message-ID: <20020913233156.324A31C0E9@pwstephenson.fsnet.co.uk> (raw)
In-Reply-To: "Philippe Troin"'s message of "13 Sep 2002 11:25:37 PDT." <87u1ktsq5a.fsf@ceramic.fifi.org>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2119 bytes --]
Philippe Troin wrote:
> Tried on zsh 4.0.4 and 4.0.6:
>
> % for i in 1 2 3; do echo $i || break; done && echo X
> 1
> X
> 2
> X
> 3
> X
> X
> %
>
> That looks somewhat incorrect...
Oh, *yuk*.
> Or did I miss something?
Non, hélas.
The wordcode is pretty horrific to debug: it's uncommented and as an
unstructured array of integers completely opaque to all debugging tools.
Tentative patch below --- passes all tests, including the new one (which
Philippe will recognise). It's actually against 4.1, but I doubt if
much has changed here.
I may leave this till Monday for people to scratch their heads over.
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.45
diff -u -r1.45 exec.c
--- Src/exec.c 5 Aug 2002 12:35:59 -0000 1.45
+++ Src/exec.c 13 Sep 2002 23:18:57 -0000
@@ -877,8 +877,15 @@
* for this sublist. */
donetrap = 1;
goto sublist_done;
- } else if (WC_SUBLIST_TYPE(code) == WC_SUBLIST_END)
+ } else if (WC_SUBLIST_TYPE(code) == WC_SUBLIST_END) {
+ /*
+ * Treat this in the same way as if we reached
+ * the end of the sublist normally.
+ */
donetrap = 1;
+ state->pc = next;
+ goto sublist_done;
+ }
}
cmdpush(CS_CMDOR);
break;
Index: Test/A01grammar.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A01grammar.ztst,v
retrieving revision 1.5
diff -u -r1.5 A01grammar.ztst
--- Test/A01grammar.ztst 22 Aug 2001 15:59:27 -0000 1.5
+++ Test/A01grammar.ztst 13 Sep 2002 23:18:58 -0000
@@ -319,3 +319,14 @@
done < /dev/null | { read name; print done }
0:Bug regression: `while' loop with redirection and pipeline
>done
+
+# This used to be buggy and print X at the end of each loop.
+ for f in 1 2 3 4; do
+ print $f || break
+ done && print X
+0:Handling of ||'s and &&'s with a for loop in between
+>1
+>2
+>3
+>4
+>X
--
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
Work: pws@csr.com
Web: http://www.pwstephenson.fsnet.co.uk
next prev parent reply other threads:[~2002-09-13 23:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-13 18:25 Philippe Troin
2002-09-13 23:31 ` Peter Stephenson [this message]
2002-09-14 0:34 ` Bart Schaefer
2002-09-14 0:58 ` Philippe Troin
2002-09-14 4:56 ` Bart Schaefer
2002-09-16 4:58 ` Philippe Troin
2002-09-16 6:25 ` Bart Schaefer
2002-09-16 18:26 ` Philippe Troin
2002-09-16 20:46 ` Hans Dieter Pearcey
2002-09-17 0:08 ` Philippe Troin
2002-09-14 14:39 ` Peter Stephenson
2002-09-17 10:47 ` Peter Stephenson
2002-09-29 13:20 ` Sven Wischnowsky
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=20020913233156.324A31C0E9@pwstephenson.fsnet.co.uk \
--to=pws@pwstephenson.fsnet.co.uk \
--cc=zsh-workers@sunsite.auc.dk \
/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).