Re: Append newline to files



On Tue, 29 Jul 2008 20:14:01 +0000, Jürgen Exner wrote:

Martijn Lievaart <m@xxxxxxxxxxxxxxxx> wrote:
2) Or investigate if it are only the Windows files missing a trailing
lineseparator, it's a typical Windows problem.

And here you just fell into the trap.

If "\n" is a line _seperator_, then a trailing line separator would
simply indicate another emtpy line at the end of the file:
"foo\nbar\n"
would contains 3 lines, 'foo', 'bar' and an empty line.

If on the other hand "\n" is a line _terminator_ then the above string
would contain 2 lines. And
"foo\nbar\n\buzz"
would still be only two lines with some trailing junk.

You're right. But on Windows, it's a line separator[1]. On Unix, it's a
line terminator. So there is no correct way.

M4

[1] Although many programs follow Unix conventions, so it's ill advised
to rely on this.

.