[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: read -t

From: isabella parakiss
Subject: Re: read -t
Date: Sun, 4 Jan 2015 17:43:29 +0100

Ok, that makes sense, but why doesn't it work if I change the delimiter?

read -t 3 -d q       *press random keys without pressing q*

I think the same should happen here, I'm asking bash to read as much input as
it can until it reads a q.  Since I don't press q, whatever I typed should be
used as typeahead.  But that's not the case, and I don't understand why.

2015-01-04 17:21 GMT+01:00, Chet Ramey <address@hidden>:
> On 1/4/15 12:45 AM, isabella parakiss wrote:
>> I'm trying to use read -t in an interactive shell
>> read -t 3   *press random keys*
>> Everything i press is now part of the next command in the prompt.
>> It only happens when the delimiter is a \n.
>> Is this intended? What's the point?
> It's difficult for me to tell what the question is here.  You've asked
> for bash to read as much input as it can until it reads a newline, with
> the read aborted if you don't press a newline within three seconds.  Since
> you don't press newline, read(2) doesn't return anything and whatever
> you've typed is left in the input buffer as typeahead for readline.  When
> readline is called, it is able to read all of the typeahead and use it as
> part of the next input line.
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]