Hi
I'm not really involved with apt development, but I've strong opinions
when it comes to terminal applications.
The value of $TERM refers to a terminfo / termcap definition / file. If
a terminal supports color, and which escape sequences they need for
them, is specified inside those files.
The name of the files (and thus the value of the $TERM variable), does
not necessarily have to contain "color" if the terminfo / termcap
definition specify the capabilities for color, and vice versa.
Additionally, not all terminals may use the same escape sequence for
colors either.
I think the root cause of the problem is escape sequences being
hardcoded in apt, that simply should never be done. An application
should always make use of the terminfo database when outputting any
escape sequence.
This will also make it trivial not to output escape sequences on dumb
terminals, since there'll simply be no cap / escape sequence in the
terminfo definition to output in that case.
For colors, this may be helpful:
https://stackoverflow.com/questions/42734416/how-to-set-colors-in-terminal-using-terminfo
It seams there are a few places with hard coded escape sequences, but
it's not too bad yet:
https://salsa.debian.org/search?search=033&group_id=2051&project_id=228&scope=&search_code=true&snippets=false&repository_ref=main&nav_source=navbar
Regards,
Daniel Abrecht