#988570 lesspipe: improve manpage

Package:
less
Source:
less
Description:
pager program similar to more
Submitter:
Christoph Anton Mitterer
Date:
2021-05-16 01:12:04 UTC
Severity:
wishlist
#988570#5
Date:
2021-05-16 01:09:35 UTC
From:
To:
Hi.

1) lesspipe mangpage says:

It would be nice if there was a note, that the script uses SHELL to determine
the output, but SHELL isn't re-set by e.g. bash, if already set.

So one should ideally invoke the above like:
eval "$(SHELL=/name/of/the/actual/shell lessfile)"


2) if [ -z "$PS1" ]; then
       exit
   fi

Is IMO a bad check for interactiveness (and it shouldn't be exit, but return?):

a) This will break if PS1 is unset and "set -u" is active, ${PS1-} would solve this.
b) But IMO it's anyway better to check for "i" in $-.
   A user could have set an empty prompt (unlikely, but possible) and then the shell
   would be considiered non-interactive - while it's not.
   Also, PS1 could always be there in non-interactive shell (by accident).

   OTOH, AFAIU, "i" in $- is really only set by the shell if it considers itself
   interactive.

   The following should be a proper check for that:
   if [ -n "${-##*i*}"  -o  -z "${-}" ]; then
	return
   fi

   It's better than the various constructs with case or [[ since it's posix compatible,
   and not prone to shopt nocasematch being on.


Cheers,
Chris.