zsh-workers
 help / color / mirror / code / Atom feed
From: "Andrej Borsenkow" <borsenkow.msk@sni.de>
To: "Bernd Eggink" <eggink@uni-hamburg.de>,
	"zsh Workers" <zsh-workers@math.gatech.edu>
Subject: RE: typeahead problem
Date: Tue, 8 Dec 1998 18:54:44 +0300	[thread overview]
Message-ID: <001101be22c3$12fde9b0$21c9ca95@mowp.siemens.ru> (raw)
In-Reply-To: <366D40E8.EAB05EE2@rrz.uni-hamburg.de>

>
> No. For example, try this script:
>
>   for i in {1..}
>   do if read -q "REPLY?y/n: "
>      then print yes
>      else print no
>      fi
>      sleep 1
>   done
>
> After the first prompt, type aa quickly (or any other characters). On
> Linux and AIX, I get
>
>   y/n: a
>   no
>   ay/n: n
>   no
>   ay/n: n
>   no
>   ay/n: n
>   no
>   ay/n: n
>   no
>   $ a
>

On 3.1.5-patched I cannot reproduce it. It behaves exactly as I described.
It _smells_ like CLOBBERS_TYPEAHED though ...

> where $ stands for the shell prompt.
>
> I guess the problem is getzlequery() in Zle/zle_utils.c. The comment
> says: "If there are any characters in the buffer, this is taken as a
> negative response, and no characters are read."

No, what is called is getquery(); zlegetquery() is used only when you have
too long completion list.

 guess, this happens exactly because your system does _not_ clobbers
typeahed :)) getquery() can be told to purge input - but read -q does not do
it; it sees typeahed, takes it for "no", and then is called again - but
nothing was ever read from terminal, so it sees the same input again ...

As to why it is taken for "no" - imagine, you typed something _before_
read -q, and that was not completely consumed - you definitely does not want
some leftover "y" to remove your valuable files :) so it tries to play safe.

The only thing I don't understand, why it works on my system ...

This sounds like an
> exact description of what happens, and doesn't seem to make much sense.
> Why aren't the characters in the buffer read?? OTOH, there is no such
> bug on HP-UP, so I hesitate to hack the sources blindly...
>

there is not on my system as well ... but funnily enough, it probably means
a bug on my system :))  The ultimate place to correct it is bin_read(); call
getquery with last argument 1.

/andrej


  reply	other threads:[~1998-12-08 15:57 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 [this message]
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

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='001101be22c3$12fde9b0$21c9ca95@mowp.siemens.ru' \
    --to=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).