* Bug in select
@ 1998-07-01 18:21 Bernd Eggink
1998-07-03 16:15 ` PATCH: " Bart Schaefer
0 siblings, 1 reply; 4+ messages in thread
From: Bernd Eggink @ 1998-07-01 18:21 UTC (permalink / raw)
To: Zsh-workers
Zsh-3.1.4 has a bug in 'select': An empty user input is not treated
correctly, due to a misconstructed do-loop (in do ... while(0) break and
continue have the same effect).
Here is a patch:
--- loop.c.old Wed Jul 1 19:19:26 1998
+++ loop.c Wed Jul 1 19:28:28 1998
@@ -156,7 +156,7 @@
inp = fdopen(dup((SHTTY == -1) ? 0 : SHTTY), "r");
selectlist(args);
for (;;) {
- do {
+ for (;;) {
if (empty(bufstack)) {
if (interact && SHTTY != -1 && isset(USEZLE))
str = (char *)zleread(prompt3, NULL, 0);
@@ -178,11 +178,10 @@
}
if ((s = strchr(str, '\n')))
*s = '\0';
- if(!*str) {
+ if(*str)
+ break;
selectlist(args);
- continue;
- }
- } while(0);
+ };
setsparam("REPLY", ztrdup(str));
i = atoi(str);
if (!i)
--
Bernd Eggink
Regionales Rechenzentrum der Uni Hamburg
eggink@uni-hamburg.de
http://www.rrz.uni-hamburg.de/eggink/BEggink.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* PATCH: Re: Bug in select
1998-07-01 18:21 Bug in select Bernd Eggink
@ 1998-07-03 16:15 ` Bart Schaefer
0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 1998-07-03 16:15 UTC (permalink / raw)
To: Zsh-workers
On Jul 1, 8:21pm, Bernd Eggink wrote:
} Subject: Bug in select
}
} Zsh-3.1.4 has a bug in 'select': An empty user input is not treated
} correctly, due to a misconstructed do-loop
I couldn't get this patch to apply, probably because some mailer along
the way munged the whitespace.
Here it is again, with indentation cleaned up (was Bernd's patch made
with "diff -bw ..."?).
Index: Src/loop.c
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-3.1/Src/loop.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 loop.c
--- loop.c 1998/06/01 17:08:44 1.1.1.1
+++ loop.c 1998/07/03 16:11:36
@@ -156,7 +156,7 @@
inp = fdopen(dup((SHTTY == -1) ? 0 : SHTTY), "r");
selectlist(args);
for (;;) {
- do {
+ for (;;) {
if (empty(bufstack)) {
if (interact && SHTTY != -1 && isset(USEZLE))
str = (char *)zleread(prompt3, NULL, 0);
@@ -178,11 +178,10 @@
}
if ((s = strchr(str, '\n')))
*s = '\0';
- if(!*str) {
- selectlist(args);
- continue;
- }
- } while(0);
+ if (*str)
+ break;
+ selectlist(args);
+ };
setsparam("REPLY", ztrdup(str));
i = atoi(str);
if (!i)
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: bug in select
1996-12-29 3:28 bug " Yamamoto Hirotaka
@ 1996-12-29 23:15 ` Zoltan Hidvegi
0 siblings, 0 replies; 4+ messages in thread
From: Zoltan Hidvegi @ 1996-12-29 23:15 UTC (permalink / raw)
To: ymmt; +Cc: zsh-workers
> Hi,
>
> I found a buggy feature in zsh's `select' built-in command.
> here's the log.
>
> verdy% select i in aaa bbb ccc
> do echo $i
> done
> 1) aaa 2) bbb 3) ccc
> ?# 1
> 0
I bet that i is integer here. Look:
hzoli% select i in aaa bbb ccc
do echo $i
done
1) aaa 2) bbb 3) ccc
?# 1
aaa
1) aaa 2) bbb 3) ccc
?#
hzoli% integer i
hzoli% select i in aaa bbb ccc
do echo $i
done
1) aaa 2) bbb 3) ccc
?# 1
0
1) aaa 2) bbb 3) ccc
?#
Ksh behaves exactly the same way. This is not a bug. Add unset i before
select and it'll work. Note that i becomes integer if it is initialised
first in an arithmetic expression, like let i=0 or $((i=0)).
Zoltan
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug in select
@ 1996-12-29 3:28 Yamamoto Hirotaka
1996-12-29 23:15 ` Zoltan Hidvegi
0 siblings, 1 reply; 4+ messages in thread
From: Yamamoto Hirotaka @ 1996-12-29 3:28 UTC (permalink / raw)
To: zsh-workers
Hi,
I found a buggy feature in zsh's `select' built-in command.
here's the log.
verdy% select i in aaa bbb ccc
do echo $i
done
1) aaa 2) bbb 3) ccc
?# 1
0
1) aaa 2) bbb 3) ccc
?# 2
0
1) aaa 2) bbb 3) ccc
?# 3
0
1) aaa 2) bbb 3) ccc
?# 0
0
1) aaa 2) bbb 3) ccc
?# aaa
0
1) aaa 2) bbb 3) ccc
with zsh version 3.1.0, Linux-2.0.27 (Slakware-3.1)
ps) I cannot understand the usage of `&|' and `&!'.
could someone help me?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1998-07-03 16:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-07-01 18:21 Bug in select Bernd Eggink
1998-07-03 16:15 ` PATCH: " Bart Schaefer
-- strict thread matches above, loose matches on Subject: below --
1996-12-29 3:28 bug " Yamamoto Hirotaka
1996-12-29 23:15 ` Zoltan Hidvegi
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).