[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How many chars read -r line can read from tty?
From: |
Lawrence Velázquez |
Subject: |
Re: How many chars read -r line can read from tty? |
Date: |
Wed, 15 May 2024 17:50:49 -0400 |
User-agent: |
Cyrus-JMAP/3.11.0-alpha0-456-gcd147058c-fm-hotfix-20240509.001-g0aad06e4 |
On Wed, May 15, 2024, at 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.
>
> If I try a string with length 1023, it will finish correctly and print 1023.
>
> Anybody know why there is such a limit?
Bash has no such limit, but macOS does:
https://superuser.com/q/219225
https://unix.stackexchange.com/q/204815
As does Linux (albeit a somewhat higher one):
https://unix.stackexchange.com/q/131105
--
vq