bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: sed : * final newline


From: Stepan Kasal
Subject: Re: sed : * final newline
Date: Tue, 8 Jul 2003 17:10:37 +0200
User-agent: Mutt/1.2.5.1i

Hello,

On Tue, Jul 08, 2003 at 11:00:03AM -0400, Karl Berry wrote:
>     OK.  I'd still prefer to append newline at the no matter what the input
>     looked like, ie. the Solaris way.
>     I think this is the cleanest way---it has only one drawback, which can be
>     easily expressed: ``if the input file doesn't end with newline, a newline
>     will be appended.
>
> Isn't that a fairly significant drawback?  Just off the cuff, I don't
> expect tools to alter my input files unless I ask them to.

well, the problem is the definition of the text file.
If you pipe a non-text file through a text utility (like sed), you may
expect problems.
Strictly said, when the final newline is missing, it's not a text file.

If you consider it a text file, as if the ending newline were there,
you won't probably mind when a tool appends it. (A)
BTW: AFAIK, vim behaves this way.

If you consider it a text file, and you consider the fact that the newline
is missing as important, then you may be annoyed that a tool added it. (B)

My position is (A), as I have already said.  Because of people which feel
like (B), sed contains the hack which tries to preserve the ending for
simple sed scripts.  But this hack causes problems when the program is
not so trivial or when sed gets several input files.
Thus Paolo proposed another dirty trick to solve the annoying side
effects of the hack.

I hope Paolo will reply again to this mail, and I'm going to respect his
decision.

Stepan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]