From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13214 invoked from network); 8 Dec 1998 18:40:36 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 8 Dec 1998 18:40:36 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id NAA21386; Tue, 8 Dec 1998 13:39:27 -0500 (EST) Resent-Date: Tue, 8 Dec 1998 13:39:27 -0500 (EST) From: "Andrej Borsenkow" To: "Bart Schaefer" , "zsh Workers" Subject: RE: typeahead problem Date: Tue, 8 Dec 1998 21:38:13 +0300 Message-ID: <001a01be22d9$e99fbc80$21c9ca95@mowp.siemens.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2377.0 Importance: Normal In-Reply-To: <981208100629.ZM6018@candle.brasslantern.com> X-MimeOLE: Produced By Microsoft MimeOLE V5.00.0810.800 Resent-Message-ID: <"W4UyK2.0.2E5.V9NRs"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4722 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu > -----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