On Mon, Nov 01, 2021 at 07:33:58PM -0600, Todd C. Miller wrote:
> On Mon, 01 Nov 2021 20:20:49 -0500, Scott Cheloha wrote:
> 
> > On the one hand, it is intuitive that two buffers are not literally
> > the same if one has a newline and the other does not.  strcmp(3)
> > agrees with this.
> >
> > ... On the other hand, it also seems intuitive that two records are
> > the same even if one record doesn't have a record delimiter.  You
> > could argue that this makes the utility more flexible in a small
> > corner case.
> 
> I think we do want it.  However, wouldn't it be simpler to always
> strip the trailing newline and emit a newline in show() unconditionally?
> I realize this would add a newline if one was missing but that
> doesn't seem like a bad thing to me and is what GNU and FreeBSD do.

Yes it would be simpler.  However I didn't want to start changing the
input -- which we currently don't do -- without discussing it.

The standard says we should "write one copy of each input line on the
output." So, if we are being strict, we don't add a newline that isn't
there, because that isn't what we read.  Any other interpretation
requires handwaving about what an "input line" even is.

So, I guess I'm unsure.  I love the simplicity of the unconditional
newline but modifying the input makes me nervous.

If additional people are fine with adding the maybe-missing newline I
can make it unconditional.  Aligning our behavior with other
implementations in this corner case is probably reasonable.

Reply via email to