summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2010-02-14 17:11:00 +0000
committerMike Frysinger <vapier@gentoo.org>2010-02-14 17:11:00 +0000
commit85d63d9e991acbf167771bf5399c949ed1631838 (patch)
treeecb26a9afd8b8b24740922979be3e927cd28f6b3 /sys-apps
parentCorrected wrong naming of patch (diff)
downloadgentoo-2-85d63d9e991acbf167771bf5399c949ed1631838.tar.gz
gentoo-2-85d63d9e991acbf167771bf5399c949ed1631838.tar.bz2
gentoo-2-85d63d9e991acbf167771bf5399c949ed1631838.zip
Rework lesspipe to fallback to the coloring tool rather than maintaining a list of matches #304359 by Dror Levin. Start renaming lesspipe.sh to lesspipe to better match other distros. Tip people to run `lesspipe -h` for color info #274457 by Jaak Ristioja.
(Portage version: 2.2_rc62/cvs/Linux x86_64)
Diffstat (limited to 'sys-apps')
-rw-r--r--sys-apps/less/ChangeLog9
-rw-r--r--sys-apps/less/files/lesspipe.sh56
-rw-r--r--sys-apps/less/less-436.ebuild9
3 files changed, 40 insertions, 34 deletions
diff --git a/sys-apps/less/ChangeLog b/sys-apps/less/ChangeLog
index bfdd552c5079..74e549c3cfd0 100644
--- a/sys-apps/less/ChangeLog
+++ b/sys-apps/less/ChangeLog
@@ -1,6 +1,13 @@
# ChangeLog for sys-apps/less
# Copyright 1999-2010 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-apps/less/ChangeLog,v 1.115 2010/02/05 06:36:58 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/less/ChangeLog,v 1.116 2010/02/14 17:10:59 vapier Exp $
+
+ 14 Feb 2010; Mike Frysinger <vapier@gentoo.org> less-436.ebuild,
+ files/lesspipe.sh:
+ Rework lesspipe to fallback to the coloring tool rather than maintaining a
+ list of matches #304359 by Dror Levin. Start renaming lesspipe.sh to
+ lesspipe to better match other distros. Tip people to run `lesspipe -h`
+ for color info #274457 by Jaak Ristioja.
05 Feb 2010; Mike Frysinger <vapier@gentoo.org> files/lesspipe.sh:
Fix handling of short tarball names #303433 by Mike Williams, and add a
diff --git a/sys-apps/less/files/lesspipe.sh b/sys-apps/less/files/lesspipe.sh
index 948075808b8c..7211dffde746 100644
--- a/sys-apps/less/files/lesspipe.sh
+++ b/sys-apps/less/files/lesspipe.sh
@@ -175,34 +175,6 @@ lesspipe() {
isoinfo -l ${iso_opts} -i "$1"
;;
- ### Source code ###
- *.awk|*.groff|*.java|*.js|*.m4|*.php|*.pl|*.pm|*.pod|*.sh|\
- *.ad[asb]|*.asm|*.inc|*.[ch]|*.[ch]pp|*.[ch]xx|*.cc|*.hh|\
- *.lsp|*.l|*.pas|*.p|*.xml|*.xps|*.xsl|*.axp|*.ppd|*.pov|\
- *.diff|*.patch|*.py|*.rb|*.sql|*.ebuild|*.eclass)
-
- # Allow people to flip color off if they dont want it
- case ${LESSCOLOR} in
- always) LESSCOLOR=2;;
- [yY][eE][sS]|1|true) LESSCOLOR=1;;
- [nN][oO]|0|false) LESSCOLOR=0;;
- *) LESSCOLOR=0;; # default to no color #188835
- esac
- [[ ${LESSCOLORIZER+set} != "set" ]] && LESSCOLORIZER=code2color
- if [[ ${LESSCOLOR} == "0" ]] || [[ -z ${LESSCOLORIZER} ]] ; then
- # let less itself handle these files
- exit 0
- fi
-
- # 2: Only colorize if user forces it ...
- # 1: ... or we know less will handle raw codes -- this will
- # not detect -seiRM, so set LESSCOLORIZER yourself
- if [[ ${LESSCOLOR} == "2" ]] || [[ " ${LESS} " == *" -"[rR]" "* ]] ; then
- ${LESSCOLORIZER} "$1"
- exit 0
- fi
- ;;
-
# May not be such a good idea :)
# ### Device nodes ###
# /dev/[hs]d[a-z]*)
@@ -226,6 +198,29 @@ lesspipe() {
lesspipe_file "$1"
fi
+ # So no matches from above ... finally fall back to an external
+ # coloring package. No matching here so we don't have to worry
+ # about keeping in sync with random packages. Any coloring tool
+ # you use should not output errors about unsupported files to
+ # stdout. If it does, it's your problem.
+
+ # Allow people to flip color off if they dont want it
+ case ${LESSCOLOR} in
+ always) LESSCOLOR=2;;
+ [yY][eE][sS]|[yY]|1|true) LESSCOLOR=1;;
+ [nN][oO]|[nN]|0|false) LESSCOLOR=0;;
+ *) LESSCOLOR=0;; # default to no color #188835
+ esac
+ if [[ ${LESSCOLOR} != "0" ]] && [[ -n ${LESSCOLORIZER=code2color} ]] ; then
+ # 2: Only colorize if user forces it ...
+ # 1: ... or we know less will handle raw codes -- this will
+ # not detect -seiRM, so set LESSCOLORIZER yourself
+ if [[ ${LESSCOLOR} == "2" ]] || [[ " ${LESS} " == *" -"[rR]" "* ]] ; then
+ ${LESSCOLORIZER} "$1"
+ fi
+ fi
+
+ # Nothing left to do but let less deal
exit 0
;;
esac
@@ -235,10 +230,9 @@ if [[ -z $1 ]] ; then
echo "Usage: lesspipe.sh <file>"
elif [[ $1 == "-V" || $1 == "--version" ]] ; then
Id="cvsid"
- cvsid="$Id: lesspipe.sh,v 1.38 2010/02/10 23:56:59 vapier Exp $"
cat <<-EOF
- $cvsid
- Copyright 2001-2009 Gentoo Foundation
+ $Id: lesspipe.sh,v 1.39 2010/02/14 17:11:00 vapier Exp $
+ Copyright 2001-2010 Gentoo Foundation
Mike Frysinger <vapier@gentoo.org>
(with plenty of ideas stolen from other projects/distros)
diff --git a/sys-apps/less/less-436.ebuild b/sys-apps/less/less-436.ebuild
index b6620c1384e2..b54fda924ef5 100644
--- a/sys-apps/less/less-436.ebuild
+++ b/sys-apps/less/less-436.ebuild
@@ -1,6 +1,6 @@
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-apps/less/less-436.ebuild,v 1.10 2010/01/10 17:47:11 ulm Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/less/less-436.ebuild,v 1.11 2010/02/14 17:10:59 vapier Exp $
inherit eutils
@@ -35,8 +35,13 @@ src_install() {
emake install DESTDIR="${D}" || die
dobin code2color || die "dobin"
- newbin "${FILESDIR}"/lesspipe.sh lesspipe.sh || die "newbin"
+ newbin "${FILESDIR}"/lesspipe.sh lesspipe || die "newbin"
+ dosym lesspipe /usr/bin/lesspipe.sh
newenvd "${FILESDIR}"/less.envd 70less
dodoc NEWS README* "${FILESDIR}"/README.Gentoo
}
+
+pkg_postinst() {
+ einfo "lesspipe offers colorization options. Run 'lesspipe.sh -h' for info."
+}