wofr06 / lesspipe

lesspipe - display more with less
GNU General Public License v2.0
484 stars 51 forks source link

Fix usage instructions for bourne shell (sh/bash). #149

Closed 4kbyte closed 5 months ago

4kbyte commented 5 months ago

The fix is self-evident as a matter of syntax. With the previous instruction to eval lesspipe.sh, the shell will execute lesspipe.sh but simply echo its result to stdout. To set LESSOPEN the output needs to be eval'd, so capture it with the shell's $() command substitution.

Demonstration:

$ unset LESSOPEN
$ eval lesspipe.sh
LESSOPEN="|/usr/bin/lesspipe.sh %s"
export LESSOPEN
$ echo $LESSOPEN

$ eval "$(lesspipe.sh)"
$ echo $LESSOPEN
|/usr/bin/lesspipe.sh %s

Tested with GNU bash, version 5.1.16 (and a busybox sh).

wofr06 commented 5 months ago

In Ubuntu 24_04 there is a default .bashrc file. There is a line to do the same for another version of lesspipe. I t was not present yet in Ubuntu 22_04. I changed my .bashrc to contain # make less more friendly for non-text input files, see lesspipe(1) [ -x /usr/local/bin/lesspipe.sh ] && eval "$(SHELL=/bin/sh lesspipe.sh)"