zsh-workers
 help / color / mirror / code / Atom feed
From: "Andrej Borsenkow" <borsenkow.msk@sni.de>
To: "Bart Schaefer" <schaefer@brasslantern.com>,
	"zsh Workers" <zsh-workers@math.gatech.edu>
Subject: RE: typeahead problem
Date: Tue, 8 Dec 1998 21:38:13 +0300	[thread overview]
Message-ID: <001a01be22d9$e99fbc80$21c9ca95@mowp.siemens.ru> (raw)
In-Reply-To: <981208100629.ZM6018@candle.brasslantern.com>



> -----Original Message-----
> From: Bart Schaefer [mailto:schaefer@brasslantern.com]
>
>
> I see the following in a patched 3.0.5 and in both patched and unpatched
> 3.1.5:
>
> zagzig% while read -q && sleep 5
> while> do echo YES; done
> y				<-- newline echoed immediately
> yyyYES				<-- I typed yyy, YES echoed
> after 5 sec.
> n				<-- echoed immediately after YES
> zagzig% yyy			<-- typeahead now appears at the prompt
>
> } Well, manual says "read -q reads only one character" so it is really
> } confusing. Currently it "reads the line and takes the first character".
> } Who's wrong - binary or manual?
>
> On my system, at least, zsh does not consume the line, only the first y
> of the four that I typed.  That agrees with the manual, except that the
> manual doesn't discuss the typeahead behavior.
>

I know now, what happens here. See later

> 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.

In other words, if system does have FIONREAD but clobbers typeahead, zsh
always reads the first character and forgets the rest. CLOBBER_TYPEAHED is
used in zsetterm() but not in getquery() ... I think it is quite possible
... Well, do we need to change modes (setcbreak()) _before_ doing read? that
is, if FIONREAD is defined we check and either output NL
and return or read up typeahead and go on. the same, if we read the first
character of typeahead instead of assuming "no".

/andrej


  reply	other threads:[~1998-12-08 18:40 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 [this message]
1998-12-08 18:38             ` Bernd Eggink
1998-12-08 21:22               ` 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='001a01be22d9$e99fbc80$21c9ca95@mowp.siemens.ru' \
    --to=borsenkow.msk@sni.de \
    --cc=schaefer@brasslantern.com \
    --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).