On Sep 18, 2025, 13:55 Chet Ramey wrote:
> On 9/17/25 12:02 PM, Pourko wrote:
> > As a side question, wouldn't it make more sense if read -d"" -t 0
> > makes the read in raw mode?
> 
> What would that do to change things? (I assume that you mean a non-
> blocking read; `raw mode' has historically meant something different.)

Well, I kind of did mean `raw mode'. So, let me try to rephrase the 
whole thing:

Basically, we have these two options:
`read -t 0'
`read -t $nonzero'

Either of these works as advertised, no problem so far.

If we add to each of them the `-d ""' option, then:

`read -d "" -t $nonzero' will slurp in all outstanding keys, regardless of 
whether or not the RETURN key has been pressed.

But for
read -d "" -t 0', the 
-d' option will make no difference, and 
it will still leave keys behind -- those that have been typed in, but
not yet followed by a RETURN key. And this is precisely what bugs me here:
I wish that `read -d "" -t 0' would also slurp in everything that's
already available, when given the `-d ""' option.

As things are now, one has no way to check from within a tight loop
whether some key has been pressed -- not without a wasteful timeout
option, or without an expensive external call to set the term raw.

--
Pourko


  • CORRECTED: Bug i... pourko--- via Bug reports for the GNU Bourne Again SHell
    • Re: CORRECT... Chet Ramey
      • Re: COR... pourko--- via Bug reports for the GNU Bourne Again SHell
      • Re: COR... pourko--- via Bug reports for the GNU Bourne Again SHell
        • Re:... Chet Ramey
          • ... pourko--- via Bug reports for the GNU Bourne Again SHell
            • ... Chet Ramey
              • ... pourko--- via Bug reports for the GNU Bourne Again SHell
                • ... Chet Ramey
          • ... pourko--- via Bug reports for the GNU Bourne Again SHell
      • Re: COR... pourko--- via Bug reports for the GNU Bourne Again SHell
    • Re: CORRECT... pourko--- via Bug reports for the GNU Bourne Again SHell
    • Re: CORRECT... pourko2--- via Bug reports for the GNU Bourne Again SHell

Reply via email to