mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Markus Wichmann <>
Subject: Re: [musl] What determines the TERM variable value?
Date: Sat, 12 Feb 2022 11:33:56 +0100	[thread overview]
Message-ID: <20220212103356.GB8426@voyager> (raw)
In-Reply-To: <>

On Sat, Feb 12, 2022 at 11:34:52AM +0200, Yuri Kanivetsky wrote:
> So, a program is a terminal emulator if it translates escape sequences
> in both directions? And if it, as a result, changes the TERM variable?

A program is a terminal emulator if it emulates a terminal, i.e.
provides an interface for TUI applications to interact with a keyboard
and screen (and optionally a mouse). The Linux VT provides such a thing
directly, X11 applications like xterm do so via the X11 protocol. Screen
and tmux are men in the middle, implementing screen and keyboard via
another terminal emulator. But still, they are terminal emulators.

The TERM variable is not somehow especially protected. Any process can
change it at any time, and it will remain changed for that process and
any child processes until one of those decides to change it again. To

> What seems strange to me is that docker changes the TERM variable:
> $ echo $TERM
> screen-256color
> $ docker run --rm -it alpine
> / # echo $TERM
> xterm

Anyone can change the TERM variable, including docker. I think, they
assume that xterm is a least common denominator among terminal
emulators. Also, the xterm terminfo is most likely to be installed in
whatever container you are running.

Leaving aside the technical meaning of the TERM variable, what it is
used for most often is to find the terminfo database for the terminal.
That is a file on the local file system, and must be installed to be
effective. If, for example, I connect from my normal terminal emulator
to a remote host via ssh, and I transmit a TERM variable of
"stterm-256color", then this will not help the apps on the far side of
the connection to figure out how to talk to my terminal if the stterm
terminfo file is not installed. My options then are to install it or
look for a terminfo file that is installed and sufficiently similar to
my terminal to make it work. Likely shedding some features in the
process (e.g. you can make almost anything work by setting TERM to
vt100, but then you loose all colors).

Similarly, it is nice for you to be using screen as a terminal in the
host, but docker likely does not want to assume that the screen terminfo
is installed in the container, and that is where it would need to be for
the container to make any use of it.

That said, docker is a highly flexible piece of software, so I would be
surprised if this functionality was not configurable somehow.


  reply	other threads:[~2022-02-12 10:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-11 13:30 Yuri Kanivetsky
2022-02-11 15:54 ` Rich Felker
2022-02-12  9:34   ` Yuri Kanivetsky
2022-02-12 10:33     ` Markus Wichmann [this message]
2022-02-12 15:05       ` Rich Felker
2022-02-13  8:54         ` Yuri Kanivetsky
2022-02-13  9:57           ` Markus Wichmann
2022-02-17 20:37             ` [musl] RE: [EXTERNAL] " Andy Caldwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220212103356.GB8426@voyager \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).