From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19857 invoked from network); 28 Feb 1997 16:45:06 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by coral.primenet.com.au with SMTP; 28 Feb 1997 16:45:06 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id LAA12521; Fri, 28 Feb 1997 11:24:13 -0500 (EST) Resent-Date: Fri, 28 Feb 1997 11:24:13 -0500 (EST) From: "Bart Schaefer" Message-Id: <970228083159.ZM22775@candle.brasslantern.com> Date: Fri, 28 Feb 1997 08:31:59 -0800 In-Reply-To: (Zoltan T. Hidvegi) "Re: case $? fails" (Feb 27, 4:50pm) References: <9702272150.AA15381@lotto.fishkill.ibm.com> Reply-To: schaefer@nbn.com X-Mailer: Z-Mail (4.0b.820 20aug96) To: zsh-workers@math.gatech.edu Subject: Re: case $? fails MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"6h5xx2.0.a33.jQm5p"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2945 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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