Bug 294499 - [termcap] screen entry has so=\E[3m (italic) should be so=\E[7m (reverse video)
Summary: [termcap] screen entry has so=\E[3m (italic) should be so=\E[7m (reverse video)
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: 14.3-RELEASE
Hardware: amd64 Any
: --- Affects Some People
Assignee: Cy Schubert
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-04-14 00:52 UTC by Dan Mahoney
Modified: 2026-04-28 14:23 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Mahoney 2026-04-14 00:52:58 UTC
The screen entry in /etc/termcap has incorrect values for the standout mode capabilities:

:se=\E[23m:so=\E[3m:

\E[3m is the ANSI escape sequence for italic, not standout/reverse video. The correct values are:

:se=\E[27m:so=\E[7m:

This can be confirmed by noting that mr=\E[7m (reverse video) is correctly defined in the same entry — the right escape sequence was available but placed in the wrong capability.

The screen-256color entry inherits from screen via tc=screen and is therefore also affected.

The practical effect is that applications linking against base libtinfow display italic text where reverse video highlighting is expected. Confirmed with Alpine 2.26 inside a GNU Screen 5.0.1 session on FreeBSD 14.

The fix is a one-line correction in the screen entry in /etc/termcap:

:se=\E[23m:so=\E[3m:   should be   :se=\E[27m:so=\E[7m:

Note that this entry ships in FreeBSD base and is present even on systems where the sysutils/screen port has never been installed.
Comment 1 Dan Mahoney 2026-04-14 04:23:57 UTC
Note: There's a related bug in Gnu Screen due to this behavior change.

When screen was set up to support italics: (via this bug):

https://savannah.gnu.org/bugs/?36676, 

people originally complained that it showed standout instead of italics.  So screen added italics, but this exposed that inside many termcaps, including FreeBSD's, we're sending the wrong sequences.

There's now an open PR in screen that it should do the right thing natively (this bug:)

https://savannah.gnu.org/bugs/?func=detailitem&item_id=67436

But this can also be fixed by fixing the various system termcap entries.

I've got a pull request ready to go for this (which can easily be backported if desired).

Note that there may in fact be more new capabilities that gnu screen supports, and it may be worth updating this entry more fully.  This just fixes the glaring error.  If I need to upload broken screenshots of (say) Alpine, which relies heavily on reverse video, I can.

-Dan
Comment 2 Dan Mahoney 2026-04-14 04:26:53 UTC
https://github.com/freebsd/freebsd-src/pull/2139
Comment 3 Dan Mahoney 2026-04-19 22:51:32 UTC
I've looped the gnu screen freebsd maintainer in on this, cy@.
Comment 4 Dan Mahoney 2026-04-19 23:16:54 UTC
Additional note on why the base termcap fix is necessary independent of any Screen-side workaround:

The sysutils/screen port at version 5.0.1_6 emits a runtime workaround by writing duplicate so= and se= entries into $TERMCAP, with the correct reverse-video values appearing after the broken italic ones:

  so=\E[3m:se=\E[23m:so=\E[7m:se=\E[27m

Termcap parsers generally take the last occurrence, so this works in the local session. However, $TERMCAP is not forwarded over SSH -- OpenSSH's SendEnv does not include it, and AcceptEnv on the remote side typically only lists $TERM. When a user SSHes from a machine running Screen to another machine and runs an affected application there, the remote system looks up the screen entry in its own /etc/termcap, encounters only the broken so=\E[3m, and displays italics instead of reverse video.

Confirmed: with the per-user ~/.terminfo workaround removed on the remote system, the bug reappears immediately upon SSH. With the base /etc/termcap fix applied, no per-user workaround would be needed.

This means the Screen port's runtime duplicate-entry approach, while useful, cannot substitute for fixing the base entry. The correct fix has to live in /etc/termcap itself.
Comment 5 Dan Mahoney 2026-04-19 23:17:08 UTC
Additional note on why the base termcap fix is necessary independent of any Screen-side workaround:

The sysutils/screen port at version 5.0.1_6 emits a runtime workaround by writing duplicate so= and se= entries into $TERMCAP, with the correct reverse-video values appearing after the broken italic ones:

  so=\E[3m:se=\E[23m:so=\E[7m:se=\E[27m

Termcap parsers generally take the last occurrence, so this works in the local session. However, $TERMCAP is not forwarded over SSH -- OpenSSH's SendEnv does not include it, and AcceptEnv on the remote side typically only lists $TERM. When a user SSHes from a machine running Screen to another machine and runs an affected application there, the remote system looks up the screen entry in its own /etc/termcap, encounters only the broken so=\E[3m, and displays italics instead of reverse video.

Confirmed: with the per-user ~/.terminfo workaround removed on the remote system, the bug reappears immediately upon SSH. With the base /etc/termcap fix applied, no per-user workaround would be needed.

This means the Screen port's runtime duplicate-entry approach, while useful, cannot substitute for fixing the base entry. The correct fix has to live in /etc/termcap itself.
Comment 6 commit-hook freebsd_committer freebsd_triage 2026-04-22 03:06:04 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=2bff747bb04db6beb19678abc45edd96be0a1347

commit 2bff747bb04db6beb19678abc45edd96be0a1347
Author:     Dan Mahoney <github@gushi.org>
AuthorDate: 2026-04-14 03:53:51 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2026-04-22 03:03:23 +0000

    termcap: fix screen entry standout mode (so/se) capabilities

    so=\E[3m (italic) is incorrect, should be so=\E[7m (reverse video).
    se=\E[23m (italic off) is incorrect, should be se=\E[27m (reverse off).

    mr=\E[7m (reverse video) is correctly defined in the same entry.
    screen-256color inherits from screen via tc=screen and is fixed
    transitively.

    PR:             294499
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/2139
    MFC after:      1 week

    Signed-off-by: Dan Mahoney <freebsd@gushi.org>

 share/termcap/termcap | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 7 Cy Schubert freebsd_committer freebsd_triage 2026-04-22 03:08:24 UTC
Fix has bee committed. I will close this PR when it's been MFCed.
Comment 8 commit-hook freebsd_committer freebsd_triage 2026-04-28 14:21:37 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=7dcfbf4a8bf3553993569b3a3c5bca906e8f450a

commit 7dcfbf4a8bf3553993569b3a3c5bca906e8f450a
Author:     Dan Mahoney <github@gushi.org>
AuthorDate: 2026-04-14 03:53:51 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2026-04-28 14:19:25 +0000

    termcap: fix screen entry standout mode (so/se) capabilities

    so=\E[3m (italic) is incorrect, should be so=\E[7m (reverse video).
    se=\E[23m (italic off) is incorrect, should be se=\E[27m (reverse off).

    mr=\E[7m (reverse video) is correctly defined in the same entry.
    screen-256color inherits from screen via tc=screen and is fixed
    transitively.

    PR:             294499
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/2139

    Signed-off-by: Dan Mahoney <freebsd@gushi.org>
    (cherry picked from commit 2bff747bb04db6beb19678abc45edd96be0a1347)

 share/termcap/termcap | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 9 commit-hook freebsd_committer freebsd_triage 2026-04-28 14:21:38 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=4c2563e16b401c31e82917476be1411422d6557e

commit 4c2563e16b401c31e82917476be1411422d6557e
Author:     Dan Mahoney <github@gushi.org>
AuthorDate: 2026-04-14 03:53:51 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2026-04-28 14:19:48 +0000

    termcap: fix screen entry standout mode (so/se) capabilities

    so=\E[3m (italic) is incorrect, should be so=\E[7m (reverse video).
    se=\E[23m (italic off) is incorrect, should be se=\E[27m (reverse off).

    mr=\E[7m (reverse video) is correctly defined in the same entry.
    screen-256color inherits from screen via tc=screen and is fixed
    transitively.

    PR:             294499
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/2139

    Signed-off-by: Dan Mahoney <freebsd@gushi.org>
    (cherry picked from commit 2bff747bb04db6beb19678abc45edd96be0a1347)

 share/termcap/termcap | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 10 commit-hook freebsd_committer freebsd_triage 2026-04-28 14:22:39 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=2a32297a6d9f0c82e64d315239693fcf4bc7bc23

commit 2a32297a6d9f0c82e64d315239693fcf4bc7bc23
Author:     Dan Mahoney <github@gushi.org>
AuthorDate: 2026-04-14 03:53:51 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2026-04-28 14:20:05 +0000

    termcap: fix screen entry standout mode (so/se) capabilities

    so=\E[3m (italic) is incorrect, should be so=\E[7m (reverse video).
    se=\E[23m (italic off) is incorrect, should be se=\E[27m (reverse off).

    mr=\E[7m (reverse video) is correctly defined in the same entry.
    screen-256color inherits from screen via tc=screen and is fixed
    transitively.

    PR:             294499
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/2139

    Signed-off-by: Dan Mahoney <freebsd@gushi.org>
    (cherry picked from commit 2bff747bb04db6beb19678abc45edd96be0a1347)

 share/termcap/termcap | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 11 Cy Schubert freebsd_committer freebsd_triage 2026-04-28 14:23:38 UTC
This can be closed now.