On 9/22/25 12:28 PM, [email protected] wrote:

 > while read -t 0; do
 >         read -N 1 v
 >         var+=v
 > done

No, your snippet won't detect anything if keys have been typed in but the
RETURN key has no been pressed yet.

Yes, you're right. The problem is that the test for pending input happens
before (or without) the terminal settings change that would take place
before a read when -n/-N/-d are supplied.

I think it's reasonable to change the terminal settings before testing for
available input if those options are supplied.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    [email protected]    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

  • 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