From 14aa2dffe8627e17e9a858642744648fa466a2a7 Mon Sep 17 00:00:00 2001 From: Martin Väth Date: Thu, 7 Apr 2016 21:15:26 +0200 Subject: Follow gentoo concerning handling of lesspipe --- sys-apps/less/files/code2color-0.2.patch | 26 -------------------------- sys-apps/less/files/lesspipe.sh | 27 +++++++++++++++++---------- 2 files changed, 17 insertions(+), 36 deletions(-) delete mode 100644 sys-apps/less/files/code2color-0.2.patch (limited to 'sys-apps/less/files') diff --git a/sys-apps/less/files/code2color-0.2.patch b/sys-apps/less/files/code2color-0.2.patch deleted file mode 100644 index f8a78250..00000000 --- a/sys-apps/less/files/code2color-0.2.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- code2color -+++ code2color -@@ -163,11 +163,11 @@ - # building up the database - # newer entries overwrite old ones - my @CONFIG_FILES; -- push @CONFIG_FILES, "/etc/code2html.config"; -+ push @CONFIG_FILES, "/etc/code2color"; - push @CONFIG_FILES, -- $ENV{'HOME'}."/.code2html.config" if $ENV{'HOME'}; -+ $ENV{'HOME'}."/.code2color" if $ENV{'HOME'}; - push @CONFIG_FILES, -- split(/:/,$ENV{'CODE2HTML_CONFIG'}) if $ENV{'CODE2HTML_CONFIG'}; -+ split(/:/,$ENV{'CODE2COLOR_CONFIG'}) if $ENV{'CODE2COLOR_CONFIG'}; - push @CONFIG_FILES, - split(/:/,$params{'langfile'}) if $params{'langfile'}; - -@@ -3192,7 +3192,7 @@ - # - - $LANGUAGE{'shellscript'} = { -- 'filename' => '\\.(sh|shell)$', -+ 'filename' => '\\.(ebuild|eclass|sh|shell)$', - 'regex' => '^\\s*#\\s*![^\\s]*(sh|bash|ash|zsh|ksh)', - 'patterns' => [ { - 'name' => 'comment', 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 " 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 (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 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} ]] \ -- cgit v1.2.3-65-gdbad