Your message dated Mon, 28 Aug 2017 13:05:31 -0600
with message-id <[email protected]>
and subject line Re: Bug#873476: coreutils: /bin/cat doesnt display a line of a
txt file without an end of line
has caused the Debian Bug report #873476,
regarding coreutils: /bin/cat doesnt display a line of a txt file without an
end of line
to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)
--
873476: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=873476
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: coreutils
Version: 8.26-3
Severity: normal
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I've a "VERSION" file for a package (not from debian) and this file doesnt have
a 0x0A at the end of the line.
cat doesnt display any contents (less does).
If I add lines before the offending line, these lines are displayed but not the
last one.
Attached: the VERSION file which contain a single line and the TXT file which
contains 2 lines, the second one without a 0x0A.
Regards
Jean-Luc
- -- System Information:
Debian Release: buster/sid
APT prefers unstable
APT policy: (600, 'unstable'), (500, 'buildd-unstable'), (500, 'testing'),
(1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 4.13.0-rc6-i7-0.1 (SMP w/8 CPU cores; PREEMPT)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8),
LANGUAGE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages coreutils depends on:
ii libacl1 2.2.52-3+b1
ii libattr1 1:2.4.47-2+b2
ii libc6 2.24-17
ii libselinux1 2.7~rc2-1
coreutils recommends no packages.
coreutils suggests no packages.
- -- no debconf information
-----BEGIN PGP SIGNATURE-----
iF0EARECAB0WIQT5el3FKLtmYO4UlQtR0YZfPMac0AUCWaPJZAAKCRBR0YZfPMac
0BWZAKCK88N2/n4tTEEeKyc+jhRklVxjXQCgnnZ/4iZ3Hv8YSuTHFZemtx4lUJg=
=knZs
-----END PGP SIGNATURE-----
3.3.7.2
first line
second line
--- End Message ---
--- Begin Message ---
Jean-Luc Coulon (f5ibh) wrote:
> I've a "VERSION" file for a package (not from debian) and this file doesnt
> have a 0x0A at the end of the line.
> cat doesnt display any contents (less does).
First is that 'cat' is not a screen display text browsing program in
the same way that 'more' and 'less' are text browsing programs. The
cat program is designed to concatenate files. Yes people have used it
to dump characters to the terminal since the beginning. But this
usage is also dependent upon their understanding that cat is simply
copying bytes to the terminal with no understanding of the binary file
contents. If the file contains text lines then text lines are dumped
to the terminal. If the file contains binary data that possibly
interacts badly with the terminal then binary data is dumped to the
terminal and the terminal will react badly to this dumping.
> If I add lines before the offending line, these lines are displayed but not
> the last one.
>
> Attached: the VERSION file which contain a single line and the TXT file which
> contains 2 lines, the second one without a 0x0A.
What happens depends entirely upon your terminal environment, the
contents of your PS1 shell prompt variable, any actions included in
your PROMPT_COMMAND variable in the case of bash, and possibly other
specifics of your environment. This is not a bug in cat. As long as
cat is copying binary bytes to the standard output then cat is
behaving correctly.
Because this is not a bug in cat I am going to mark the bug ticket as
closed. However please feel free to reply to the bug log and continue
exchanging information. It will then be available for other people to
read when they have similar problems and search for similar bug
tickets.
To continue with this try looking at the output of your cat program by
dumping it to a hex display such as this.
$ od -Ax -tx1z -v < VERSION
000000 33 2e 33 2e 37 2e 32 >3.3.7.2<
000007
$ cat VERSION | od -Ax -tx1z -v
000000 33 2e 33 2e 37 2e 32 >3.3.7.2<
000007
Since the binary dump of the data both from your original file and
from the output of cat are identical then cat is behaving correctly.
Most likely what you are seeing is that your PS1 or PROMPT_COMMAND is
overwriting the non-text binary output. It is non-text binary output
because it does not end with a newline. Therefore the cursor is left
at the end of the data. Then subsequently the cursor is moved to the
beginning of the line and the data is overwritten.
You can simulate this data easily with 'printf' without a newline.
Try playing with these commands and see the problems that arise.
$ printf "hello world"
hello world$
$ printf "hello world\n"
hello world
$
$ printf 3.3.7.2
3.3.7.2$
$ printf "3.3.7.2\n"
3.3.7.2
$
In my case I have a very simple PS1 and PROMPT_COMMAND is not set.
But if you have other settings then often user's PS1 setting will move
the cursor to the start of the line and will overwrite the contents of
the line with the PS1 prompt covering the data that was sent to the
terminal.
Bob
signature.asc
Description: PGP signature
--- End Message ---