From: <hzoli@VNET.IBM.COM> (Zoltan T. Hidvegi)
To: roderick@argon.org (Roderick Schertler)
Cc: zsh-workers@math.gatech.edu
Subject: Re: case $? fails
Date: Thu, 27 Feb 1997 16:50:03 -0500 (EST) [thread overview]
Message-ID: <9702272150.AA15381@lotto.fishkill.ibm.com> (raw)
In-Reply-To: <7139.857070506@eeyore.ibcinc.com> from Roderick Schertler at "Feb 27, 97 02:08:26 pm"
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) {
next prev parent reply other threads:[~1997-02-27 21:59 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 [this message]
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
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=9702272150.AA15381@lotto.fishkill.ibm.com \
--to=hzoli@vnet.ibm.com \
--cc=roderick@argon.org \
--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).