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

Re: apt show escape characters



On Sat 08 Nov 2025 at 09:50:37 (-0500), Greg Wooledge wrote:
> On Fri, Nov 07, 2025 at 23:26:18 -0600, David Wright wrote:
> > I don't understand. When did less get involved in a simple command
> > like   apt show bash   ?
> 
> "Pipe the output through a pager automatically" has become a thing in
> recent years.  systemctl does it too.  man has always done it, but for
> a very long time it was unique.
> 
> > 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 do have PAGER=less in my environment.  Here are the relevant
> variables for my setup:
> 
> PAGER=less
> LESS=-X
> EDITOR=vim
> VISUAL=vim
> 
> If PAGER is not set, programs that want to launch a pager will select
> one themselves.  Traditionally, they would select more(1).  On Debian,
> man(1) appears to select "pager":

… which in my case runs less through the /etc/alternatives symlinks,
rather than via PAGER (unset). I've now eliminated MANOPT, set since
sometime back in the 1990s. I have   alias lessx='less -X'
as I don't usually want the file contents left on the screen.

Your inability to replicate my output came down to the LESS
environment variable, which I did have set thoughout my tests.
Sorry about that. I use less a lot, and so I've configured it a fair
bit. I haven't edited the configuration file for two or three years,
so I'd missed that there's a LESS setting at the bottom of the file,
which I think that makes changing or unsetting LESS at the commandline
impossible, as the lesskey file just adds it again. So I've moved it
out of the lesskey file into .bashrc, meaning it can be overridden
if necessary.

So   man ls   works perfectly, honouring the lesskey file's command
definitions and line-editing keys, and the options set by LESS too.
Setting PAGER= avoids paging altogether.

As you pointed out, systemctl also runs a pager; here it's also less,
still honouring the lesskey file, but ignoring the options in LESS.

The webpage on the ubuntu bug mentions the APT_PAGER variable,
which has the advantage that it only affects APT, so I've set
it to 'less -Riqs' in .bashrc. That fixes the bug, honours the
lesskey file, and merges the options in LESS with ones in the
commandline. By merges, I mean that toggle-options that are in
both LESS and the commandline don't get toggled twice (in my
case, -i and -s).

The output from ps shows an extra process running:

  apt show bash
   /bin/sh -c less -Riqs
    less -Riqs

> I control boldface and underlining by setting terminal resources.
> I'm using rxvt-unicode.  Underlining works automatically, and I use a
> blue color for boldface text:
> 
> rxvt*saveLines:			2000
> rxvt*colorBD:			navy blue
> ; rxvt*colorUL:			red
> rxvt*color2:			ForestGreen
> rxvt*color7:			white
> ; rxvt*color4:			PowderBlue
> rxvt*cutchars:			\\ `\047\042();<>[]{|},
> rxvt*scrollBar_floating:	false

I'l have to see how xterm does this, and/or perhaps check out rxvt
when I have the time, thanks.

Cheers,
David.


Reply to: