Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sat, 12 Feb 2022 10:05:25 -0500
From: Rich Felker <>
To: Markus Wichmann <>,
	Yuri Kanivetsky <>
Subject: Re: What determines the TERM variable value?

On Sat, Feb 12, 2022 at 11:33:56AM +0100, Markus Wichmann wrote:
> 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
> wit:
> > 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.

If that's what's happening, Docker is just wrong to be doing this.
xterm is one of the most over-featured terminals out there, and the
terminfo for it reflects that. TERM=xterm is not likely to actually
work for most terminals if the application actually tries to make use
of any of the advanced features (though it might appear to work as
long as they stick to basics).

The appropriate TERM setting for a minimal common denominator where
you don't know the actual terminal type is probably something like
vt102 or vt220. But really Docker just shouldn't munge it.

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

Yeah, it's probably configurable.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.