summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'sys-apps/less/files/lesspipe.sh')
-rw-r--r--sys-apps/less/files/lesspipe.sh27
1 files changed, 17 insertions, 10 deletions
diff --git a/sys-apps/less/files/lesspipe.sh b/sys-apps/less/files/lesspipe.sh
index 6edaa3ce..291d6d66 100644
--- a/sys-apps/less/files/lesspipe.sh
+++ b/sys-apps/less/files/lesspipe.sh
@@ -59,6 +59,15 @@ lesspipe() {
[[ ${match} == *.${ignore} ]] && exit 0
done
+ # Handle non-regular file types.
+ if [[ -d $1 ]] ; then
+ ls -alF -- "$1"
+ return
+ elif [[ ! -f $1 ]] ; then
+ stat "$1"
+ return
+ fi
+
case "${match}" in
### Doc files ###
@@ -90,7 +99,8 @@ lesspipe() {
esac
;;
*.dvi) dvi2tty "$1" ;;
- *.ps|*.pdf) ps2ascii "$1" || pstotext "$1" || pdftotext "$1" ;;
+ *.ps) ps2ascii "$1" || pstotext "$1" ;;
+ *.pdf) pdftotext "$1" - || ps2ascii "$1" || pstotext "$1" ;;
*.doc) antiword "$1" || catdoc "$1" ;;
*.rtf) unrtf --nopict --text "$1" ;;
*.conf|*.txt|*.log) ;; # force less to work on these directly #150256
@@ -234,14 +244,12 @@ lesspipe() {
if [[ -z $1 ]] ; then
echo "Usage: lesspipe <file>"
elif [[ $1 == "-V" || $1 == "--version" ]] ; then
- Id="cvsid"
cat <<-EOF
- $Id$
- Copyright 2001-2013 Gentoo Foundation
+ lesspipe (git)
+ Copyright 2001-2016 Gentoo Foundation
Mike Frysinger <vapier@gentoo.org>
(with plenty of ideas stolen from other projects/distros)
-
EOF
less -V
elif [[ $1 == "-h" || $1 == "--help" ]] ; then
@@ -251,21 +259,20 @@ elif [[ $1 == "-h" || $1 == "--help" ]] ; then
Usage: lesspipe <file>
lesspipe specific settings:
- LESSCOLOR env - toggle colorizing of output (no/yes/always)
+ LESSCOLOR env - toggle colorizing of output (no/yes/always; default: no)
LESSCOLORIZER env - program used to colorize output (default: code2color)
LESSIGNORE - list of extensions to ignore (don't do anything fancy)
You can create per-user filters as well by creating the executable file:
~/.lessfilter
- One argument is passed to it: the file to display.
+ One argument is passed to it: the file to display. The script should exit 0
+ to indicate it handled the file, or non-zero to tell lesspipe to handle it.
To use lesspipe, simply add to your environment:
export LESSOPEN="|lesspipe %s"
- Run 'less --help' or 'man less' for more info
+ Run 'less --help' or 'man less' for more info.
EOF
-elif [[ -d $1 ]] ; then
- ls -alF -- "$1"
else
recur=0
[[ -n ${LESSDEBUG} ]] \