Bug 869403

Summary: systemd prints raw escape codes if $LESS options set
Product: [Fedora] Fedora Reporter: Jeff Bastian <jbastian>
Component: systemdAssignee: systemd-maint
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: 17CC: johannbg, lnykryn, metherid, mschmidt, msekleta, notting, plautrba, systemd-maint, vpavlin
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-10-24 13:29:51 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jeff Bastian 2012-10-23 19:30:45 UTC
Description of problem:
systemd prints raw escape codes if custom options are set in the $LESS environment variable.

For example, use the -F option to auto-quit if the output fits in the terminal:

$ export LESS="-F"
$ systemd-delta
ESC[1;32m[EQUIVALENT]ESC[0m /etc/systemd/system/default.target → /usr/lib/systemd/system/default.target

1 overridden configuration files found.

Personally, I have in my ~/.bashrc 
  export LESS="-FiX"

If I unset the $LESS environment variable, then I get green text for "[EQUIVALENT]"

$ unset LESS
$ systemd-delta
[EQUIVALENT] /etc/systemd/system/default.target → /usr/lib/systemd/system/defaul
^^^^^^^^^^^^
   green

I see this with other systemd commands also, e.g., systemctl list-units tries to print "failed" in red letters, but I get this:

systemd-...-clean.service loaded ESC[1;31mfailed failed   ESC[0m     Cleanup of Temporary Directories
systemd-...-setup.service loaded ESC[1;31mfailed failed   ESC[0m     Recreate Volatile Files and Directories

Side-note: those units failed because of bug 857708


Version-Release number of selected component (if applicable):
systemd-44-20.fc17.x86_64
less-444-5.fc17.x86_64

How reproducible:
every time

Steps to Reproduce:
1. set your favorite options in the $LESS environment variable
   export LESS="-F"
2. systemd-delta
3. systemctl list-units
  
Actual results:
Ugly raw escape codes like ESC[1;31m are printed

Expected results:
Red or green text, or plain uncolored text if colors not possible

Additional info:

Comment 1 Jeff Bastian 2012-10-23 19:36:00 UTC
A workaround is to use the --no-pager option (where applicable):

$ systemd-delta --no-pager
[EQUIVALENT] /etc/systemd/system/default.target → /usr/lib/systemd/system/default.target

1 overridden configuration files found.


$ systemctl list-units --no-pager | less
...
systemd-...-clean.service loaded failed failed        Cleanup of Temporary Direc
systemd-...-setup.service loaded failed failed        Recreate Volatile Files an
...

Comment 2 Michal Schmidt 2012-10-24 13:29:51 UTC
It's the same underlying issue as in bug 868383.

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