After an update I noticed that my bash profile for man
colorization breaks paging. I don't know what changed but I narrowed it down to the fact that calling env less hello.txt
results in contents of hello.txt
being echoed to the terminal (like cat
) without the paging behavior. How do I debug and fix this?
To eliminate the effect of some environment variables, I tested with the minimal environment:
env -i TERM=xterm-256color /usr/bin/less hello.txt
or even:
env -i /usr/bin/less hello.txt
This also simply prints the file to stdout. On a different machine with the same software versions, the paging works (if TERM
is preserved).
Since even env -i
behaves differently, I don't suppose that the reason is something in my environment.
Versions of less
and env
are the same: less 581.2 (PCRE2 regular expressions)
and GNU coreutils 8.32
, OS is Arch Linux 64 bit, up to date, shell: GNU bash, version 5.1.8(1)-release (x86_64-pc-linux-gnu)
.
less
an alias or function? What doestype less; type env
output?less
to be sure, but I didn't think ofenv
. If I do/usr/bin/env
instead, it works. The alias comes from the samegrc
package:env is aliased to 'colourify env'
.env
is a simple tool with a simple job and messing with it is bound to create this kind of weird problem.grc -es
, where-es
means that it redirects the stdout and stderr of invoked commands. Not sure how the redirection is used, but I guessless
detects it and changes behavior accordingly.less
behaves likecat
when its output is not a terminal, so that you can have a program (such asman
) automatically pipe toless
, but still pipe its output if you want.