Unable to change color highlight in apt output

Bug #2020812 reported by StevenT
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
apt (Ubuntu)
New
Undecided
Unassigned

Bug Description

Ubuntu Release:
lsb_release -rd
Description: Ubuntu 22.04.2 LTS
Release: 22.04

Source package and version:
dpkg-query -W apt
apt 2.4.9

Binary apt command has support for color output on some commands such as "apt list <packagename>" Where enabled the default color output is unbolded green color. This is due to the apt configuration item, APT::Color::Highlight being set to the default ANSI color code of "\x1B[32m", Setting it to another ANSI code should alter the apt output.

Expectation:Setting the Highlight configuration option to another ANSI code should alter the apt output to the specified color code.

$ apt list apt -o apt::color::highlight="\x1b[31m" should set the highlighted package name to an unbold red color.

What happens:
$ apt list apt -o apt::color::highlight="\x1b[31m"
Listing... Done
\x1b[31mapt/jammy-updates,now 2.4.9 amd64 [installed,automatic]
\x1b[31mapt/jammy-updates 2.4.9 i386

Prepends literal string of \x1b[31m instead of producing colored output.

"\033[31m" doesn't work either.

Revision history for this message
Julian Andres Klode (juliank) wrote :

I think you need to url encode the sequence, but not sure. I don't think there's anything we can do here about handling backslashes, the problem is backspaces do happen in actual config items and we can't introduce a behavior change for them as that would cause regressions.

You should be free to also printf the actual special character into the config option or the command line argument.

Revision history for this message
StevenT (steventhompson) wrote : Re: [Bug 2020812] Re: Unable to change color highlight in apt output

On 5/26/23 12:27 AM, Julian Andres Klode wrote:
> I think you need to url encode the sequence, but not sure. I don't think
> there's anything we can do here about handling backslashes, the problem
> is backspaces do happen in actual config items and we can't introduce a
> behavior change for them as that would cause regressions.
>
> You should be free to also printf the actual special character into the
> config option or the command line argument.
>

Thanks, the printf worked.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.