Package: less
Version: 551-2
Severity: wishlist

Hi.

1) lesspipe mangpage says:
>USAGE
>       Just  put  one of the following two commands in your login script (e.g.
>       ~/.bash_profile):
>         eval "$(lessfile)"
>       or
>         eval "$(lesspipe)"

This is however not enough in some cases, which lead to #385168 long ago.

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.

Reply via email to