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
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).
env -i behaves differently, I don't suppose that the reason is something in my environment.
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).
lessan alias or function? What does
type less; type envoutput?
lessto be sure, but I didn't think of
env. If I do
/usr/bin/envinstead, it works. The alias comes from the same
env is aliased to 'colourify env'.
envis a simple tool with a simple job and messing with it is bound to create this kind of weird problem.
grc -es, where
-esmeans that it redirects the stdout and stderr of invoked commands. Not sure how the redirection is used, but I guess
lessdetects it and changes behavior accordingly.
catwhen its output is not a terminal, so that you can have a program (such as
man) automatically pipe to
less, but still pipe its output if you want.