Bug 1465815 - xterm: Character in last column of terminal gets erased in certain cases (depends on char coloring)
xterm: Character in last column of terminal gets erased in certain cases (dep...
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: xterm (Show other bugs)
25
Unspecified Linux
unspecified Severity medium
: ---
: ---
Assigned To: Miroslav Lichvar
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-06-28 05:35 EDT by Florian Weimer
Modified: 2017-06-28 10:19 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1459451
Environment:
Last Closed: 2017-06-28 10:19:16 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Florian Weimer 2017-06-28 05:35:06 EDT
+++ 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.
Comment 1 Miroslav Lichvar 2017-06-28 10:19:16 EDT
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

Note You need to log in before you can comment on or make changes to this bug.