nano-devel
[Top][All Lists]
Advanced

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

Re: [Nano-devel] RFC: was the removal of the automatic newline a good id


From: Kamil Dudka
Subject: Re: [Nano-devel] RFC: was the removal of the automatic newline a good idea?
Date: Tue, 02 Apr 2019 14:12:40 +0200

On Tuesday, April 2, 2019 1:27:17 PM CEST Benno Schulenberg wrote:
> Hi all,
> 
> Soon after the release of nano-4.0, we got this report:
>   https://savannah.gnu.org/bugs/?55997
> 
> It says that POSIX defines a text file as a bunch of lines that each end
> with a newline character, and that because of this definition there are
> several Unix tools (not GNU ones) that fail to process the final line of
> a file if it is not newline-terminated.
> 
> First, can anyone name a tool that skips the last, non-terminated line?

Consider the very common line-by-line processing loop in shell scripts:

while read line; do
    echo "PROCESSING: '$line'"
done

If the last line is not terminated, it will not be processed by this loop 
(because `read` returns non-zero exit status on EOF).

Kamil

> The poster of the report did not come up with any examples.
> 
> Second, I disagree that POSIX defines a text file as ending in a newline
> character, because in its definitions [1] it says:
> 
> 3.206 Line
> A sequence of zero or more non-<newline> characters plus a terminating
> <newline> character.
> 
> 3.403 Text File
> A file that contains characters organized into zero or more lines.
> 
> So, if I have some characters, say "foo", arranged into zero lines
> (meaning that there is no newline character at the end), then it is
> perfectly a text file.  No?
> 
> But third, even if there are no examples of misbehaving tools and "foo"
> by itself is a fine POSIX text file, I am sometimes annoyed by the lack
> of the automatic newline.  Because: often, for testing, I add something
> at the end of ~/.nanorc, and often I want to add several similar lines,
> so I type one row (without typing <Enter>) and then ^K and then several
> ^Us.  With the new lack of an automatic newline this results in the
> concatenation of several copies of what I typed into a single line.
> I find this annoying.
> 
> Of course, I could start to use 'set finalnewline' in may ~/.nanorc,
> but if I have come to expect an automatic newline, surely there will
> be other users who do so too.
> 
> Another example: if you start a new file, and type some text, and when
> you're at the end of a row and reread what you wrote and see a typo and
> go back and correct it, then, when you want to continue writing the text,
> I would just type <Down> to go to the next row.  But without the automatic
> newline, this does not work, you have to do <End> and <Enter> to get a new
> line.  I find this annoying.
> 
> So...  Maybe we should make the magic newline the default again?
> 
> Or must the idea of not-modifying-the-file by default outweigh the
> convenience of having always an empty line at end-of-file to go to?
> 
> Benno
> 
> [1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html







reply via email to

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