zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: zsh-workers@math.gatech.edu
Subject: Re: case $? fails
Date: Fri, 28 Feb 1997 08:31:59 -0800	[thread overview]
Message-ID: <970228083159.ZM22775@candle.brasslantern.com> (raw)
In-Reply-To: <hzoli@vnet.ibm.com> (Zoltan T. Hidvegi) "Re: case $? fails" (Feb 27,  4:50pm)

On Feb 27,  4:50pm,  (Zoltan T. Hidvegi) wrote:
} Subject: Re: case $? fails
}
} while has the same problem unfortunately.  Similarily
} for ((i=$?;;)) do echo $i; break; done
} prints zero.  The patch below fixes these.  The for syntax is new in
} zsh-3.1 so the first two hunks should be removed if the patch is applied
} against zsh-3.0.3-test4.

Here's what I came up with as a patch for 3.0.3-test4 by manually applying
the patch from Zoltan.  I *did* include the first two hunks (with one
additional change that moved the increment of the "loops" counter, to
match the context in the patch) -- so this patch may be flawed.

Can somebody tell me if this patch is correct?  Or have I broken something
that I haven't encountered yet?

--- Src/loop.c.orig	Fri Jan 31 21:24:10 1997
+++ Src/loop.c	Fri Feb 28 08:25:09 1997
@@ -40,8 +40,6 @@
     char *str;
     LinkList args;
 
-    loops++;
-    lastval = 0;
     node = cmd->u.forcmd;
     args = cmd->args;
     if (!node->inflag) {
@@ -51,6 +49,8 @@
 	for (x = pparams; *x; x++)
 	    addlinknode(args, ztrdup(*x));
     }
+    lastval = 0;
+    loops++;
     pushheap();
     while ((str = (char *)ugetnode(args))) {
 	setsparam(node->name, ztrdup(str));
@@ -168,11 +168,10 @@
 
     olderrexit = noerrexit;
     node = cmd->u.whilecmd;
-    lastval = 0;
+    oldval = 0;
     pushheap();
     loops++;
     for (;;) {
-	oldval = lastval;
 	list = (List) dupstruct(node->cont);
 	noerrexit = 1;
 	execlist(list, 1, 0);
@@ -196,6 +195,7 @@
 	    lastval = 1;
 	    break;
 	}
+	oldval = lastval;
     }
     popheap();
     loops--;
@@ -282,10 +282,10 @@
     l = node->lists;
     p = node->pats;
 
-    lastval = 0;
     word = *p++;
     singsub(&word);
     untokenize(word);
+    lastval = 0;
 
     if (node) {
 	while (*p) {

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern


      parent reply	other threads:[~1997-02-28 16:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-02-27 19:08 Roderick Schertler
1997-02-27 21:50 ` Zoltan T. Hidvegi
1997-02-28 16:20   ` Bart Schaefer
1997-02-28 16:23     ` Zoltan T. Hidvegi
1997-02-28 17:52       ` Bart Schaefer
     [not found]   ` <hzoli@vnet.ibm.com>
1997-02-28 16:31     ` Bart Schaefer [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=970228083159.ZM22775@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=schaefer@nbn.com \
    --cc=zsh-workers@math.gatech.edu \
    /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).