bug-ed
[Top][All Lists]
Advanced

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

Re: potential inconsistency with buffer modified flag


From: Andrew L. Moore
Subject: Re: potential inconsistency with buffer modified flag
Date: Sun, 10 Dec 2023 23:17:11 -0500
User-agent: Mozilla Thunderbird

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

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