Debian Bug report logs - #982208
coreutils: cat -E, --show-ends display strangely when CR (\ r) is included.

version graph

Package: coreutils; Maintainer for coreutils is Michael Stone <[email protected]>; Source for coreutils is src:coreutils (PTS, buildd, popcon).

Reported by: KenichiroMATOHARA <[email protected]>

Date: Sun, 7 Feb 2021 13:12:01 UTC

Severity: minor

Found in version coreutils/8.32-4

Reply or subscribe to this bug.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to [email protected], Michael Stone <[email protected]>:
Bug#982208; Package coreutils. (Sun, 07 Feb 2021 13:12:03 GMT) (full text, mbox, link).


Acknowledgement sent to KenichiroMATOHARA <[email protected]>:
New Bug report received and forwarded. Copy sent to Michael Stone <[email protected]>. (Sun, 07 Feb 2021 13:12:04 GMT) (full text, mbox, link).


Message #5 received at [email protected] (full text, mbox, reply):

From: KenichiroMATOHARA <[email protected]>
To: Debian Bug Tracking System <[email protected]>
Subject: coreutils: cat -E, --show-ends display strangely when CR (\ r) is included.
Date: Sun, 07 Feb 2021 22:08:31 +0900
Package: coreutils
Version: 8.32-4+b1
Severity: minor

Dear Maintainer,

When I create a text file with a newline code of "\r\n" and
`cat` with the `-E, --show-ends` option, "$" is displayed at
the beginning of the line.
When `-A, --show-all` is used, it looks normal.


- Create a file for \r\n
> $ echo 'foo
> >     $ od -c dos.txt
> 0000000   f   o   o  \r  \n  \t   b   a   r  \r  \n
> 0000013
>   bar' | tr '\n' '\r\n' > dos.txt

- `-E, --show-ends` option
> $ cat -E dos.txt
> $oo
> $       bar
> $ cat -nE dos.txt
> $    1  foo
> $    2          bar

- `-A, --show-all` option
> $ cat -A dos.txt
> foo ^M$
> ^Ibar^M$
> $ cat -nA dos.txt
>      1  foo^M$
>      2  ^Ibar^M$





-- System Information:
Debian Release: bullseye/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386, armhf, arm64

Kernel: Linux 5.10.0-3-amd64 (SMP w/4 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_CRAP, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=ja_JP.UTF-8, LC_CTYPE=ja_JP.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages coreutils depends on:
ii  libacl1      2.2.53-10
ii  libattr1     1:2.4.48-6
ii  libc6        2.31-9
ii  libgmp10     2:6.2.1+dfsg-1
ii  libselinux1  3.1-2+b2

coreutils recommends no packages.

coreutils suggests no packages.

-- no debconf information



Information forwarded to [email protected], Michael Stone <[email protected]>:
Bug#982208; Package coreutils. (Tue, 09 Feb 2021 23:03:03 GMT) (full text, mbox, link).


Acknowledgement sent to Pádraig Brady <[email protected]>:
Extra info received and forwarded to list. Copy sent to Michael Stone <[email protected]>. (Tue, 09 Feb 2021 23:03:03 GMT) (full text, mbox, link).


Message #10 received at [email protected] (full text, mbox, reply):

From: Pádraig Brady <[email protected]>
To: KenichiroMATOHARA <[email protected]>, [email protected]
Cc: Coreutils <[email protected]>
Subject: Re: Bug#982208: coreutils: cat -E, --show-ends display strangely when CR (\ r) is included.
Date: Tue, 9 Feb 2021 23:01:07 +0000
[Message part 1 (text/plain, inline)]
On 07/02/2021 13:08, KenichiroMATOHARA wrote:
> Package: coreutils
> Version: 8.32-4+b1
> Severity: minor
> 
> Dear Maintainer,
> 
> When I create a text file with a newline code of "\r\n" and
> `cat` with the `-E, --show-ends` option, "$" is displayed at
> the beginning of the line.
> When `-A, --show-all` is used, it looks normal.
> 
> 
> - Create a file for \r\n
>> $ echo 'foo
>>>      $ od -c dos.txt
>> 0000000   f   o   o  \r  \n  \t   b   a   r  \r  \n
>> 0000013
>>    bar' | tr '\n' '\r\n' > dos.txt
> 
> - `-E, --show-ends` option
>> $ cat -E dos.txt
>> $oo
>> $       bar
>> $ cat -nE dos.txt
>> $    1  foo
>> $    2          bar
> 
> - `-A, --show-all` option
>> $ cat -A dos.txt
>> foo ^M$
>> ^Ibar^M$
>> $ cat -nA dos.txt
>>       1  foo^M$
>>       2  ^Ibar^M$

I agree the current behavior is less than useful because:

  * \r\n is common a line end combination
  * catting such a file without options causes it to display normally
  * overwriting the first char with $, loses info

I propose to change the upstream coreutils project
as per the attached, to extend the --show-ends option
to show \r as ^M when the following character is \n.

thanks,
Pádraig
[cat--show-ends.diff (text/x-patch, attachment)]

Information forwarded to [email protected], Michael Stone <[email protected]>:
Bug#982208; Package coreutils. (Tue, 09 Feb 2021 23:12:02 GMT) (full text, mbox, link).


Acknowledgement sent to Jim Meyering <[email protected]>:
Extra info received and forwarded to list. Copy sent to Michael Stone <[email protected]>. (Tue, 09 Feb 2021 23:12:02 GMT) (full text, mbox, link).


Message #15 received at [email protected] (full text, mbox, reply):

From: Jim Meyering <[email protected]>
To: Pádraig Brady <[email protected]>
Cc: KenichiroMATOHARA <[email protected]>, [email protected], Coreutils <[email protected]>
Subject: Re: Bug#982208: coreutils: cat -E, --show-ends display strangely when CR (\ r) is included.
Date: Tue, 9 Feb 2021 15:07:55 -0800
On Tue, Feb 9, 2021 at 3:01 PM Pádraig Brady <[email protected]> wrote:
...
> I agree the current behavior is less than useful because:
>
>    * \r\n is common a line end combination
>    * catting such a file without options causes it to display normally
>    * overwriting the first char with $, loses info
>
> I propose to change the upstream coreutils project
> as per the attached, to extend the --show-ends option
> to show \r as ^M when the following character is \n.

+1 patch looks fine. Thanks!



Send a report that this bug log contains spam.


Debian bug tracking system administrator <[email protected]>. Last modified: Tue May 13 08:45:12 2025; Machine Name: bembo

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU General Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.