[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#49925: cat -E interprets sentinel newline at the end of buffer as an
bug#49925: cat -E interprets sentinel newline at the end of buffer as an actual newline after a \r
Sat, 7 Aug 2021 15:07:32 +0200
Mozilla/5.0 (X11; Linux x86_64; rv:92.0) Gecko/20100101 Thunderbird/92.0a1
(unreleased), the behavior of cat -E was changed so that it prints "^M$"
for "\r\n" line endings.
Whenever it sees a \r "cat -E" checks if the byte after is a \n, however
that \n might be the sentinel value that is inserted at the end of a buffer.
This is a problem in two cases:
- When a \r is at the end of the input. `printf "\r" | cat -E` will
print "^M", even though there is no "\n" after the "\r". FWIW,
tests/misc/cat-E.sh expects a "^M" for a trailing "\r", but I think
- When the file is too big to fit into one buffer. If you try to "cat
-E" a big file (mutliple megabytes) that consists of only "\r", cat will
print a few "^M" whenever it hits the end of a buffer in the middle of
the file and at the end.
- bug#49925: cat -E interprets sentinel newline at the end of buffer as an actual newline after a \r,
Michael Debertol <=