Re: sh(1) read: add LINE_MAX safeguard and "-n" option

Greg Troxel <[email protected]>
Newsgroups gmane.os.netbsd.devel.userlevel
Message-ID <[email protected]>
Robert Elz <[email protected]> writes:

>     Date:        Tue, 24 Sep 2024 12:56:49 +0200
>     From:        <[email protected]>
>     Message-ID:  <[email protected]>
>
>   | The present patch does two things:
>   |
>   | 1) Set, by default, the maximum of bytes read, in every case, as being
>   | LINE_MAX (the maximum number of bytes in a line in a text file);
>
> I am not really in favour of that part, while allowed by the standard,
> imposing unnecessary limits, just because they are permitted, is not
> really ideal.   Apart from that, the "line" read by read (without -r)
> can actually be several (or many) text file lines, if each is ended by
> a \ (line continuation).

Sure, but the problem is that if you have a file which is e.g one line
(single \n at end) that is 10 MB, read from it is unreasonable, and it's
difficult to deal with this in portable code.

If there were a limit which was well under 1 MB, but well over anything
reasonably in a bona fide text file, it would finesse the issue.

Perhaps 32 * LINE_MAX.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.