help-bash
[Top][All Lists]
Advanced

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

Re: How many chars read -r line can read from tty?


From: Chet Ramey
Subject: Re: How many chars read -r line can read from tty?
Date: Wed, 15 May 2024 17:59:45 -0400
User-agent: Mozilla Thunderbird

On 5/15/24 4:47 PM, Peng Yu wrote:
Hi,

read -r line; echo ${#line}

The above code does not work when the input is long. I tried to paste
to the terminal a string of 1024 characters. When I type return, I
just hear beeping. read won't finish so that the length of $line can
be printed.

man termios says:

"Each terminal device file has associated with it an input queue, into
which incoming data is stored by the system before being read by a
process.  The system imposes a limit, {MAX_INPUT}, on the number of bytes
that may be stored in the input queue."

$ grep INPUT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/syslimits.h
#define MAX_INPUT                1024   /* max bytes in terminal input */


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

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

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