Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: select behaving strange in 3.1.4



On Sep 16, 12:14am, Goran Larsson wrote:
> Subject: select behaving strange in 3.1.4
> Look at this:
> 
> $ ./select_weirdness
> 1) A  2) B  3) C
> What now?^D                                        <-- enter control-D
> $ 
> $ . ./select_weirdness
> 1) A  2) B  3) C
> What now?^D                                        <-- enter control-D
> zsh: do you wish to see all 1120 possibilities?

I see this behavior immediately, that is, it's not necessary to source
the script twice to have ^D cease to be end-of-file.  I have applied the
patch from zsh-workers/4192, which perhaps has affected the problem.

> $ . ./select_weirdness
> 1) A  2) B  3) C
> What now?^C                                        <-- enter control-C
> $ 
> $ . ./select_weirdness
> 1) A  2) B  3) C
> What now?2                                         <-- enter 2
> B
> What now?^D                                        <-- enter control-D
> zsh: do you wish to see all 1120 possibilities? n  <-- enter n
> What now?^C                                        <-- enter control-C
> 
> At this point control-C has stopped working

At this spot in getkey():

335             while ((r = read(SHTTY, &cc, 1)) != 1) {
336                 if (r == 0) {

Hitting ctrl-C returns from the read with -1 and errno == EINTR.  So we to
to this branch of the code:

351                 }
352                 icnt = 0;
353                 if (errno == EINTR) {
354                     die = 0;
355                     if (!errflag && !retflag && !breaks)
356                         continue;

The first ^C in the sample input above gets here with errflag == 1, so we
break out of the loop with EOF (which is wrong).  At the second ^C, we get
back here with NONE of errflag or retflag or breaks set, so getkey() just
tries again forever.

We just can't seem to get this tty-interrupt stuff right.  Sometimes ^C
does return from getkey() and then gets wrongly interpreted as EOF (see
http://www.zsh.org/mla/workers-1998/msg00437.html and related postings)
and other times it doesn't return on interrupt at all.

Does anybody think they know what's supposed to be happening in getkey()?



Messages sorted by: Reverse Date, Date, Thread, Author