tech-userlevel archive

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

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



Robert Elz <kre%munnari.OZ.AU@localhost> writes:

>     Date:        Tue, 24 Sep 2024 12:56:49 +0200
>     From:        <tlaronde%kergis.com@localhost>
>     Message-ID:  <ZvKa8e8a7FHIFLz6%kergis.com@localhost>
>
>   | 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.


Home | Main Index | Thread Index | Old Index