Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
May 1, 2024
Merged

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

merged 1 commit into from
May 1, 2024

Conversation

4kbyte
Copy link
Contributor

@4kbyte 4kbyte commented May 1, 2024

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).

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 wofr06 merged commit 828c3b0 into wofr06:lesspipe May 1, 2024
1 check passed
@wofr06
Copy link
Owner

wofr06 commented May 1, 2024

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)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants