From: "Bart Schaefer" <schaefer@brasslantern.com>
To: "Andrej Borsenkow" <borsenkow.msk@sni.de>,
"zsh Workers" <zsh-workers@math.gatech.edu>,
Bernd Eggink <eggink@uni-hamburg.de>
Subject: Re: typeahead problem
Date: Tue, 8 Dec 1998 13:22:28 -0800 [thread overview]
Message-ID: <981208132228.ZM6695@candle.brasslantern.com> (raw)
In-Reply-To: <001a01be22d9$e99fbc80$21c9ca95@mowp.siemens.ru>
In-Reply-To: <366D723D.A710FD4E@uni-hamburg.de>
On Dec 8, 9:38pm, Andrej Borsenkow wrote:
> Subject: RE: typeahead problem
>
> > I think the choice to pass purge==0 was partly to get consistent script
> > behavior regardless of the availablilty of FIONREAD.
>
> Unfortunately, it's not consistent. Consistent would be to read the first
> character of typeahead.
>
> About why it works and does not work.
>
> getquery() changes tty modes, and on some systems that flushes unread input
> ("clobber typeahead") Looks, like my system is so fast, that even if I type
> several characters, the first one is read by _first_ read -q, then the
> second is read by the _second_ read -q and the others are simply lost.
Your machine executes "sleep 10" so quickly that you can't type before it
finishes?
> In other words, if system does have FIONREAD but clobbers typeahead, zsh
> always reads the first character and forgets the rest.
That shouldn't be how it works. If the system clobbers typeahead in the
way described in Src/Zle/zle_main.c, then the typeahead should get lost
before getquery() has a chance to read even the first character.
However, it is the case that zsetterm() and getquery() are inconsistent
about their use of FIONREAD. zsetterm() calls ioctl(FIONREAD) _before_
attaching to the TTY, whereas getquery() attaches first and then calls
ioctl(). If the zsetterm() code doesn't cause a problem with spurious
SIGTTIN and SIGTTOU signals, it should be safe to move the FIONREAD code
in getquery() to above the attachtty() and setcbreak().
> CLOBBER_TYPEAHED is used in zsetterm() but not in getquery() ...
Yes, but that doesn't make any difference [except for the inconsistency
I just noted], because getquery() already performs an equivalent test on
the value obtained from ioctl(FIONREAD).
> ... Well, do we need to change modes (setcbreak()) _before_ doing read?
Yes, but apparently not before doing ioctl(FIONREAD).
On Dec 8, 7:38pm, Bernd Eggink wrote:
> Subject: Re: typeahead problem
> Bart Schaefer wrote:
>
> > The question is which of those two cases `read -q` should emulate. The
> > decision made was to treat it like spell checking, leaving the typeahead
> > alone when possible so that other commands may consume it.
>
> IMHO this decision was wrong, but it's probabely too late now.
Actually, I don't get the impression that `read -q` is all that widely
used, and as it's already inconsistent depending on FIONREAD, this might
be a reasonable change. We should probably float it on zsh-users first,
though.
> > get the "always consume one character" behavior is to use
> >
> > read -k1 "REPLY?Yes or no: " && do_something
>
> Hm, no. You have to write something like
>
> typeset -u REPLY
> read -k1 "REPLY?Yes or no: "
> [[ $REPLY == Y ]] && do_something
Well, yes, but you should still test for success of read. I assumed you
were already testing $REPLY inside "do_something" ... if you don't need
the answer captured in $REPLY, you can just do
read -q "?Yes or no: " && ...
prev parent reply other threads:[~1998-12-08 21:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-12-08 12:38 Bernd Eggink
1998-12-08 13:01 ` Andrej Borsenkow
1998-12-08 14:07 ` Bernd Eggink
1998-12-08 14:30 ` Andrej Borsenkow
1998-12-08 15:08 ` Bernd Eggink
1998-12-08 15:54 ` Andrej Borsenkow
1998-12-08 17:39 ` Bernd Eggink
1998-12-08 18:06 ` Bart Schaefer
1998-12-08 18:38 ` Andrej Borsenkow
1998-12-08 18:38 ` Bernd Eggink
1998-12-08 21:22 ` Bart Schaefer [this message]
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=981208132228.ZM6695@candle.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=borsenkow.msk@sni.de \
--cc=eggink@uni-hamburg.de \
--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).