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
On Tue, Sep 24, 2024 at 06:54:35PM +0700, Robert Elz wrote:
> 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).
In the present code, a delimiter can not be "any character": because
if the delimiter is the backslash, what shall be the behavior?
Since backslash is defined to be the escape character, it can not be
used as a delimiter, unless specifying that all backslashes have to
be escaped to be accepted as end delimiter... But how to specify a
continuation line then?
Shouldn't we rule out backslash as a delimiter (for -d) (and POSIX has
to be amended). Or, if backslash is a delimiter, does this imply
"raw", i.e. no escaping club?
Furthermore the continuation test on:
if (c != '\n') /* \ \n is always just removed */
goto wdch;
seems wrong. Shouldn't it be?:
if (c != end)
goto wdch;
to accept whatever continuation line with whatever delimiter?
--
Thierry Laronde <tlaronde +AT+ kergis +dot+ com>
http://www.kergis.com/
http://kertex.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C
Home |
Main Index |
Thread Index |
Old Index