Eric Blake wrote:
] Some other things we noted today: GNU ed treats 'r /dev/null' (or any
] other 0-byte file) as a command that does not modify the buffer
] changed status.  Conversely, ed on MacOS treats the buffer as modified
] even when zero bytes are read.

The reason for changing the modified status when reading /dev/null was
presumably because it allows changing the binary status of a file.
From the documentation of the GNU ed that Antonio inherited:

    When a file containing at least one ASCII **NUL** character
    is written, a newline is not appended if it did not already
    contain one upon reading. In particular, reading
    */dev/null* prior to writing prevents appending a newline
    to a binary file since */dev/null* contains no newline.


Here's a concrete example:

$ ed
a
^@
.
w o.tmp
2
r /dev/null
w
1
q
$

Since editing binary files is not part of the standard, it would be difficult justify changing a file's modified status based on this behavior.

By the way, macOS ed is a very early, buggy version of FreeBSD ed, which, in turn, is the basis of GNU ed. So, please, DO NOT use macOS ed for writing standards!

Reply via email to