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

Robert Elz <[email protected]>
Newsgroups gmane.os.netbsd.devel.userlevel
Message-ID <[email protected]>
    Date:        Tue, 24 Sep 2024 17:30:42 +0200
    From:        [email protected]
    Message-ID:  <[email protected]>

  | In the present code, a delimiter can not be "any character": because
  | if the delimiter is the backslash, what shall be the behavior?

That isn't even a half an issue ... the read reads characters until
the delimiter is encountered, then discards that, and processes the
line/record/whatever you want to call it, as directed - which includes
(assuming -r wasn't given) looking for (and eventually removing) escape
chars ... in this case it is unlikely to find any!   (But that's OK).

  | 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?

It isn't possible.   Actually using \ as the delimiter (without
-r anyway) makes little sense at all, but that doesn't mean it
needs to be prohibited.

  | Furthermore the continuation test on:
	[...]
  | seems wrong. Shouldn't it be?:
	[...]

Yes, probably - use of -d without -r is kind of rare I suspect (in
fact actually using read at all without -r is not all that common, or
not in correct code).

I will fix it along with other things - thanks.

kre
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.