+++ This bug was initially created as a clone of Bug #1459451 +++ A character in the last column of a terminal gets erased if * it is colored and the following character (if one exists) is not, OR * it is not colored and the following character is. Occurs in all environments I've tested. These include: * RHEL (over ssh) and Fedora * bash and ksh * agetty and xterm Use cases include: * colored output of grep (the most serious case I suppose) * colored output of gcc Note that a bash alias for automatic grep output colorization is present by default in both RHEL and Fedora. I don't know where the problem is, but I'm filing this against glibc, because it seems to be the most sensible factor common to all the software affected/involved. Version-Release number of selected component (if applicable): bash-4.2.46-20.el7_2.x86_64 (RHEL 7.3) bash-4.3.43-4.fc25.x86_64 (F25) ksh-20120801-31.fc25.x86_64 (F25) glibc-2.17-157.el7.x86_64 (RHEL 7.3) glibc-2.24-4.fc25.x86_64 (F25) Steps to Reproduce: $ echo $COLUMNS 23 $ alias grep alias grep='grep --color=auto' $ echo 12345678901234567890123|grep 23 1234567890123456789012 $ echo 123456789012345678901234567890|grep 3 12345678901234567890124567890 Actual results: In the first "echo|grep" call above, the last character ('3') is missing. In the second call, the last character '3' is missing in the string. Expected results: Both above "echo|grep" calls output the same string that appears as the parameter of echo. --- Additional comment from Roman Žilka on 2017-06-07 10:17:30 CEST --- Correction/observation: all the utilities that produce colored output that I've tested this on print bold+colored characters, not just colored. --- Additional comment from Florian Weimer on 2017-06-28 11:32:41 CEST --- I can reproduce this with xterm-327-2.fc25.x86_64 and with screen-4.5.1-2.fc25.x86_64 and screen-4.5.1-2.fc24.x86_64 running in a GNOME terminal. gnome-terminal-3.22.1-5.fc25.x86_64 and vte291-0.46.2-1.fc25.x86_64 do not seem to have this bug when displaying the output directly (without an intermediate screen). It is actually unrelated to grep and glibc. It looks more like a common terminal emulator bug. This command always writes the same bytes: printf '1\33[01;31m\33[K23\33[m\33[K45678901\33[01;31m\33[K23\33[m\33[K45678901\33[01;31m\33[K23\33[m\33[K\n' If the terminal is exactly 23 characters wide, the string is truncated and the last 3 is not displayed. I could reproduce this with screen-4.1.0-0.23.20120314git3c2946.el7_2.x86_64, so reassigning to that component. If you use a different terminal emulator under Red Hat Enterprise Linux 7, we need to clone this bug.
This seems to be a known problem with grep, previously discussed in bug #1006310. xterm FAQ: http://invisible-island.net/xterm/xterm.faq.html#grep_colors Upstream bug report: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=15444