Bug 5546 - less and systemctl are incompatible with each other
Summary: less and systemctl are incompatible with each other
Status: RESOLVED DUPLICATE of bug 8186
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: PC Linux
: P5 minor
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-19 15:24 UTC by holger
Modified: 2016-02-18 07:02 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description holger 2012-09-19 15:24:05 UTC
This is with Busybox 1.20.2. systemctl is using ansi color codes to turn certain words into red and green and this is printed as:

systemd-logind.service   loaded [[1;31mfailed failed   [[0m     Login Service




This appears to be the case because CLEAR_2_EOL is printed on each line.
Comment 1 Denys Vlasenko 2012-09-20 15:25:50 UTC
(In reply to comment #0)
> This is with Busybox 1.20.2. systemctl is using ansi color codes to turn
> certain words into red and green and this is printed as:
> 
> systemd-logind.service   loaded [[1;31mfailed failed   [[0m     Login Service
> 
> This appears to be the case because CLEAR_2_EOL is printed on each line.

Can you explain what command do you run? "systemctl | less"? Just "systemctl"?
Comment 2 Jonathan Liu 2013-05-16 05:53:05 UTC
This can be reproduced with:
systemctl --failed

Which outputs:
[[1;31m0 loaded units listed.[[0m Pass --all to see loaded but inactive units,
too.
To show all installed unit files use 'systemctl list-unit-files'.

The systemctl command invokes less with no arguments (unless you pass --no-pager) and includes ANSI color escape sequences in its output to less. The less command escapes character 27 in the escape sequences as it is non-printable.

Similar behavior can be observed with: ls --color / | less
Comment 3 Denys Vlasenko 2013-05-16 13:40:09 UTC
(In reply to comment #0)
> This is with Busybox 1.20.2. systemctl is using ansi color codes to turn
> certain words into red and green and this is printed as:
> 
> systemd-logind.service   loaded [[1;31mfailed failed   [[0m     Login Service

This is a bug in systemctl.
It has no right to assume pagers understand ANSI escape sequences.
Comment 4 Sam Thursfield 2015-05-20 13:41:35 UTC
I've discovered the same issue with Git v2.3.0: when 'less' in a system is Busybox 'less', `git diff` outputs ANSI colour codes which show up as text.

There'll be a way to turn this off in Git, I'm just noting it here as it's a related issue.
Comment 5 Mike Frysinger 2016-02-18 07:02:07 UTC
going to dupe to a newer bug because it's more focused

*** This bug has been marked as a duplicate of bug 8186 ***