summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Väth <martin@mvath.de>2016-04-07 21:15:26 +0200
committerMartin Väth <martin@mvath.de>2016-04-07 21:15:26 +0200
commit14aa2dffe8627e17e9a858642744648fa466a2a7 (patch)
tree2cad6867f03db9c430e55605f941d53988528351 /sys-apps/less/files/lesspipe.sh
parentnet-dns/noip-updater: Fix typo in systemd service file (diff)
downloadmv-14aa2dffe8627e17e9a858642744648fa466a2a7.tar.gz
mv-14aa2dffe8627e17e9a858642744648fa466a2a7.tar.bz2
mv-14aa2dffe8627e17e9a858642744648fa466a2a7.zip
Follow gentoo concerning handling of lesspipe
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} ]] \