diff --git a/README.md b/README.md index a4c7567..71c3c57 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,11 @@ the author by email. ``` If `lesspipe.sh` is not in the UNIX search path or if the wrong `lesspipe.sh` is found in the search path, then the full path to `lesspipe.sh` should be given - in the above commands. + in the above commands. The above commands work only in the described manner + if the file name is lesspipe.sh. + + If it is installed under a different name then calling it without an argument + will work as a filter with LESSQUIET set and expecting input from STDIN. The command to set **LESSOPEN** can also be displayed by calling `lesspipe.sh` without arguments. This can even be used to set **LESSOPEN** directly: diff --git a/lesspipe.1 b/lesspipe.1 index 99097ca..5b9c347 100644 --- a/lesspipe.1 +++ b/lesspipe.1 @@ -53,8 +53,13 @@ This can even be used to set \fBLESSOPEN\fP directly: .I lesspipe.sh|source /dev/stdin (zsh) .RE +The above commands work only in the described manner if the file name is +\fBlesspipe.sh\fP. +If it is installed under a different name then calling it without an argument +will work as a filter with \fBLESSQUIET\fP set and expecting input from STDIN. +.PP Having set the environment variable as described above, \fBless\fP -will then display textual information for a wide range of file formats. +:will then display textual information for a wide range of file formats. .PP The filter is normally not called if input is piped to less as in .RS diff --git a/lesspipe.sh b/lesspipe.sh index ebc4dbb..33f7dd7 100755 --- a/lesspipe.sh +++ b/lesspipe.sh @@ -829,7 +829,7 @@ if [[ $LESSOPEN == *\|-* && $1 == - ]]; then nexttmp >/dev/null fi -if [[ -z "$1" ]]; then +if [[ -z "$1" && "$0" == */lesspipe.sh ]]; then [[ "$0" == /* ]] || pat=$(pwd)/ if [[ "$SHELL" == *csh ]]; then echo "setenv LESSOPEN \"|$pat$0 %s\"" @@ -843,5 +843,10 @@ else elif has_cmd lessfilter; then lessfilter "$1" && exit 0 fi - show "$@" + if [[ -z "$1" ]]; then + LESSQUIET=1 + show - + else + show "$@" + fi fi