From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14010 invoked from network); 27 Feb 1997 21:59:41 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by coral.primenet.com.au with SMTP; 27 Feb 1997 21:59:41 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id QAA25904; Thu, 27 Feb 1997 16:51:47 -0500 (EST) Resent-Date: Thu, 27 Feb 1997 16:51:47 -0500 (EST) From: (Zoltan T. Hidvegi) Message-Id: <9702272150.AA15381@lotto.fishkill.ibm.com> Subject: Re: case $? fails In-Reply-To: <7139.857070506@eeyore.ibcinc.com> from Roderick Schertler at "Feb 27, 97 02:08:26 pm" To: roderick@argon.org (Roderick Schertler) Date: Thu, 27 Feb 1997 16:50:03 -0500 (EST) Cc: zsh-workers@math.gatech.edu X-Mailer: ELM [version 2.4ME+ PL31 (25)] Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"3lJV13.0.eK6.p7W5p"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2938 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Roderick Schertler wrote: > Running this script > > #!/bin/zsh -f > > print "version $ZSH_VERSION" > > false > case $? in > 0) print "case says \$? is 0";; > esac > > false > print "\$? was actually $?" > > gives me this buggy result > > version 3.0.3-test4 > case says $? is 0 > $? was actually 1 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. Note that the case bug was not present in zsh-3.0.2 but the while bug was there. Zoltan *** Src/loop.c 1997/02/11 14:23:47 3.1.2.0 --- Src/loop.c 1997/02/27 21:26:13 *************** *** 41,47 **** int val; LinkList args; - lastval = 0; node = cmd->u.forcmd; args = cmd->args; if (node->condition) { --- 41,46 ---- *************** *** 58,63 **** --- 57,63 ---- for (x = pparams; *x; x++) addlinknode(args, ztrdup(*x)); } + lastval = 0; loops++; pushheap(); for (;;) { *************** *** 267,277 **** olderrexit = noerrexit; node = cmd->u.whilecmd; ! lastval = 0; pushheap(); loops++; for (;;) { - oldval = lastval; list = (List) dupstruct(node->cont); noerrexit = 1; execlist(list, 1, 0); --- 267,276 ---- olderrexit = noerrexit; node = cmd->u.whilecmd; ! oldval = 0; pushheap(); loops++; for (;;) { list = (List) dupstruct(node->cont); noerrexit = 1; execlist(list, 1, 0); *************** *** 295,300 **** --- 294,300 ---- lastval = 1; break; } + oldval = lastval; } popheap(); loops--; *************** *** 381,390 **** l = node->lists; p = node->pats; - lastval = 0; word = *p++; singsub(&word); untokenize(word); if (node) { while (*p) { --- 381,390 ---- l = node->lists; p = node->pats; word = *p++; singsub(&word); untokenize(word); + lastval = 0; if (node) { while (*p) {