* case $? fails
@ 1997-02-27 19:08 Roderick Schertler
1997-02-27 21:50 ` Zoltan T. Hidvegi
0 siblings, 1 reply; 6+ messages in thread
From: Roderick Schertler @ 1997-02-27 19:08 UTC (permalink / raw)
To: zsh-workers
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
on both freebsd and dgux.
--
Roderick Schertler
roderick@argon.org
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: case $? fails
1997-02-27 19:08 case $? fails Roderick Schertler
@ 1997-02-27 21:50 ` Zoltan T. Hidvegi
1997-02-28 16:20 ` Bart Schaefer
[not found] ` <hzoli@vnet.ibm.com>
0 siblings, 2 replies; 6+ messages in thread
From: Zoltan T. Hidvegi @ 1997-02-27 21:50 UTC (permalink / raw)
To: Roderick Schertler; +Cc: zsh-workers
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) {
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: case $? fails
1997-02-27 21:50 ` Zoltan T. Hidvegi
@ 1997-02-28 16:20 ` Bart Schaefer
1997-02-28 16:23 ` Zoltan T. Hidvegi
[not found] ` <hzoli@vnet.ibm.com>
1 sibling, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 1997-02-28 16:20 UTC (permalink / raw)
To: Zoltan T. Hidvegi, zsh-workers
On Feb 27, 4:50pm, (Zoltan T. Hidvegi) wrote:
} Subject: Re: case $? fails
}
} 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.
The first two hunks? Or the second two hunks?
I've now tried this a couple of different ways and can't get it to apply
to 3.0.3-test4. Could you send a patch specifically for that?
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.nbn.com/people/lantern
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: case $? fails
1997-02-28 16:20 ` Bart Schaefer
@ 1997-02-28 16:23 ` Zoltan T. Hidvegi
1997-02-28 17:52 ` Bart Schaefer
0 siblings, 1 reply; 6+ messages in thread
From: Zoltan T. Hidvegi @ 1997-02-28 16:23 UTC (permalink / raw)
To: Zsh workers list
Bart Schaefer wrote:
> } 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.
>
> The first two hunks? Or the second two hunks?
>
> I've now tried this a couple of different ways and can't get it to apply
> to 3.0.3-test4. Could you send a patch specifically for that?
It applied cleanly for me after removing the first two hunks. But here is
the patch for 3.0.3-test4 anyway.
Zoltan
*** loop.c 1996/12/29 01:47:11 3.0.2.1
--- loop.c 1997/02/28 16:16:48
***************
*** 168,178 ****
olderrexit = noerrexit;
node = cmd->u.whilecmd;
! lastval = 0;
pushheap();
loops++;
for (;;) {
- oldval = lastval;
list = (List) dupstruct(node->cont);
noerrexit = 1;
execlist(list, 1, 0);
--- 168,177 ----
olderrexit = noerrexit;
node = cmd->u.whilecmd;
! oldval = 0;
pushheap();
loops++;
for (;;) {
list = (List) dupstruct(node->cont);
noerrexit = 1;
execlist(list, 1, 0);
***************
*** 196,201 ****
--- 195,201 ----
lastval = 1;
break;
}
+ oldval = lastval;
}
popheap();
loops--;
***************
*** 282,291 ****
l = node->lists;
p = node->pats;
- lastval = 0;
word = *p++;
singsub(&word);
untokenize(word);
if (node) {
while (*p) {
--- 282,291 ----
l = node->lists;
p = node->pats;
word = *p++;
singsub(&word);
untokenize(word);
+ lastval = 0;
if (node) {
while (*p) {
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: case $? fails
[not found] ` <hzoli@vnet.ibm.com>
@ 1997-02-28 16:31 ` Bart Schaefer
0 siblings, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 1997-02-28 16:31 UTC (permalink / raw)
To: zsh-workers
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: case $? fails
1997-02-28 16:23 ` Zoltan T. Hidvegi
@ 1997-02-28 17:52 ` Bart Schaefer
0 siblings, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 1997-02-28 17:52 UTC (permalink / raw)
To: Zoltan T. Hidvegi, Zsh workers list
On Feb 28, 11:23am, (Zoltan T. Hidvegi) wrote:
} Subject: Re: case $? fails
}
} Bart Schaefer wrote:
} > I've now tried this a couple of different ways and can't get it to apply
} > to 3.0.3-test4. Could you send a patch specifically for that?
}
} It applied cleanly for me after removing the first two hunks. But here is
} the patch for 3.0.3-test4 anyway.
Zoltan, all the tabs in your email message have been converted to spaces.
That's why the patch failed to apply for me; this latest one fails, too.
If I re-tabify with `unexpand -a` then it applies.
I hope this doesn't have something to do with mailing from IBM's network.
If you can't figure out why this is happening, you may have to start
base64-ing or uuencoding you patches. :-(
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.nbn.com/people/lantern
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~1997-02-28 17:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-02-27 19:08 case $? fails 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
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).