[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1010806: apt: Avoid color output on monochrome terminals



Hi,

On Mon, May 16, 2022 at 6:30 PM Adam Borowski <kilobyte@angband.pl> wrote:
> The terminfo entries stopped being maintained by late 80's.  And even if
> they were, every new terminal would need to wait several years before it can
> have its definition known by operating systems (today, distributions).
> The effect?  Most terminals identify as "xterm", "xterm-256color", or
> "rxvt".  For example both libvt (Gnome-Terminal, etc) and Konsole claim to
> be an xterm...
>
> And even if $TERM->terminfo were usable, a serial console has no way to pass
> env vars.  As an install/rescue tool, apt gets run over a serial console
> pretty often.

I think you are mistaken here. There's no need to pass environment variables,
if you run a serial terminal you are supposed to set the proper type, by using
systemd's Environment setting in serial-getty@service or otherwise
(i'm more used to gettytab). Not the other way around on the client side.
A common setting, certainly for a rescue terminal, is vt100. When you look at
terminfo you'll see it defines some common things like how to handle backspace
(this should sound familiar when you've been running *nix for some
time as it was
a big problem in the dialup era). When your function or arrow keys don't work
properly for instance this is the way to fix that.

> Thus, using terminfo is definitely not a "Right Thing" this millenium.
> Most new programs just hardcode the codes, assuming a vt100-like terminal
> with a common set of capabilities.  This includes color, as the last
> terminal without color that I remember was Windows 3.X/95's telnet.exe
> (which, per the vt100 language, ignored unknown SGR codes gracefully).

Using curses (and therefor terminfo/termcap) has been the proper way to
handle different terminals for years. Using hardcoded ansi only has become
popular the last decade or so. A vt100 does *not* support color, a thing which
terminfo tells you when you run infocmp.

$ infocmp | grep color
#       Reconstructed via infocmp from file: /lib/terminfo/s/screen-256color
screen-256color|GNU Screen with 256 colors,
        colors#0x100, cols#80, it#8, lines#24, pairs#0x10000,

$ export TERM=vt100
$ infocmp | grep color
$

Even if there are terminals which are basically 'dumb' (a serial
braille terminal
comes to mind) it should be possible to disable all color output by setting
TERM=xterm-mono when you run an xterm. It's quite rude to use color on a
monochrome terminal like this.

> Ie, this patch doesn't work, and I see no way to make it work.

The patch was the smallest addition I could think about without including
a dependency on curses. Please reconsider using color only on terminals
which 'want' to use them.

Kind regards,

Axel


Reply to: