[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: apt show escape characters



On Fri, 7 Nov 2025, David Wright wrote:

On Fri 07 Nov 2025 at 10:10:57 (-0500), Greg Wooledge wrote:
On Fri, Nov 07, 2025 at 08:37:31 -0600, Mike McClain wrote:
Since installing trixie apt show ... is displaying 'ESC[1m', 'ESC[0m'
and the like. What might be the difference in my bookworm install to
the new trixie install that would cause that?

You've probably got the LESS variable set in your environment.  I do
too.  I get that too.

If I run

    (unset LESS; apt show bash)

or

    env -u LESS apt show bash

then the raw control characters are passed through directly to the
terminal as intended.

I don't understand. When did less get involved in a simple command
like   apt show bash   ?

The only way I know in trixie for displaying the appearance as
intended is:

 PAGER= apt show bash

Who sets PAGER, I don't know. It's not shown in my environment.

I've been using   MANOPT='-P less'   for years, which gives me paging,
but also the bold and underlining that helps distinguish words having
a particular meaning from the rest of the text. This is now screwed
in trixie, in the same way as the OP's problem:

 man less                     unreadable
 MANOPT= man less             unreadable
 MANOPT= man less | less -r   readable, but bold/underlining gone
 MANOPT= man less | less -R   readable, but bold/underlining gone
 PAGER= MANOPT= man less      ? readable, with bold/underlining


Try something like (read to the stty sane bit before trying this)

MANPAGER=cat socat - EXEC:'man less',pty | less

Unfortunately, this causes some problems if you quit less rather than paging to the end due to the broken pipe.

There's probably a way to fix this but I don't know how.

stty sane

should fix the terminal again if you do this but you (probably) won't be able to see yourself typing this...

What you can do is:

MANPAGER=cat socat - EXEC:'man less',pty >less.man.txt
less less.man.txt

That way you don't ever have to worry about the broken pipe.

By ?, I mean that you can read just the final part of any long
document, depending on the size of your scrollback buffer (and
forget that on a real Linux Console). Perhaps some earlier bits
with speedy use of ^S/^Q.


This is a really frustrating thing about these tools that insist on implementing their own pagers and changing their output depending on whether the output is a TTY but don't provide adequate controls to control whether output should include control sequences or be paged.

I don't want git to page by default. I particularly hate git's habit of paging if it's more than a screen but not paging at all if it's less than a screen. So I have:

[core]
        pager = cat

Most of the time therefore I have to pass --color if I want to page it through less (which I often do). I would rather have to pass --color on the console rather than have logs polluted with escape sequences, YMMV.

However, git status does not have (that I know of) a --color option, so on the rare occasions where I want to run git status, retain colour, and also page it through less, the only way I know to do that is something like:

socat - EXEC:'git status',pty | less

All to do "git status --color | less" :-(

Tim.


Reply to: