lnav icon indicating copy to clipboard operation
lnav copied to clipboard

SYSTEMD_PAGER=lnav quits and prints ANSI escape code for colors on terminal

Open KAGEYAM4 opened this issue 6 months ago • 5 comments

lnav version v0.13.0

Describe the bug lnav will open and quit and output will be shown on treminal with ANSI escape code text prepended.

To Reproduce Set the following variables -->

  1. SYSTEMD_PAGER='lnav -q'
  2. SYSTEMD_PAGERSECURE=false
  3. systemctl cat graphical.target

Instead of opening in lnav, the following gets printed on terminal -->

[phoenix@ArchLinux ~]$ systemctl cat graphical.target
# /usr/lib/systemd/system/graphical.target
⎋[0;1;38:5:245m#  SPDX-License-Identifier: LGPL-2.1-or-later
⎋[0;1;38:5:245m#
⎋[0;1;38:5:245m#  This file is part of systemd.
⎋[0;1;38:5:245m#
⎋[0;1;38:5:245m#  systemd is free software; you can redistribute it and/or modify it
⎋[0;1;38:5:245m#  under the terms of the GNU Lesser General Public License as published by
⎋[0;1;38:5:245m#  the Free Software Foundation; either version 2.1 of the License, or
⎋[0;1;38:5:245m#  (at your option) any later version.
⎋[0;1;38:5:245m
[Unit]
Description=Graphical Interface
Documentation=man:systemd.special(7)
Requires=multi-user.target
Wants=display-manager.service
Conflicts=rescue.service rescue.target
After=multi-user.target rescue.service rescue.target display-manager.service
AllowIsolate=yes

KAGEYAM4 avatar Aug 06 '25 11:08 KAGEYAM4

I don't think this is happening anymore on the top-of-tree. Unfortunately, I'm not quite sure what I did that caused the change... sigh.

tstack avatar Aug 15 '25 18:08 tstack

This is still happening, i checked ->

  1. lnav 0.13.1 from github

  2. lnav 0.13.1-beta3-13-g26c467d from aur lnav-git

KAGEYAM4 avatar Aug 16 '25 05:08 KAGEYAM4

Ah, I think I understand now... what terminal are you using and what is TERM set to?

In the snippet you included, the escape sequence is:

[0;1;38:5:245m

lnav is expecting semi-colons and not colons for the color number (as described here -- https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit). Since it doesn't recognize the sequence, it is dumped directly to the output. It looks like colon is the truly right thing to do, so I should fix that.

Thanks for the heads up.

tstack avatar Aug 18 '25 17:08 tstack

Okay, I'm pretty sure this is fixed now.

tstack avatar Aug 19 '25 00:08 tstack

Yes, its fixed.

But lnav is still not being opened as pager for this command -> systemctl cat graphical.target

I am also conflicted to use lnav as a pager for systemctl command as some colors are still not being shown by lnav when output is piped to it. Systemd only provides one variable SYSTEMD_PAGER for both journalctl and systemctl commands.

KAGEYAM4 avatar Aug 19 '25 02:08 KAGEYAM4