Gentoo Logo
Gentoo Spaceship




Note: Due to technical difficulties, the Archives are currently not up to date. GMANE provides an alternative service for most mailing lists.
c.f. bug 424647
List Archive: gentoo-commits
Navigation:
Lists: gentoo-commits: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: gentoo-commits@g.o
From: "Mike Frysinger (vapier)" <vapier@g.o>
Subject: gentoo-x86 commit in sys-apps/less/files: lesspipe.sh
Date: Wed, 16 Apr 2008 17:33:39 +0000
vapier      08/04/16 17:33:39

  Modified:             lesspipe.sh
  Log:
  steal some more ideas from Debian: user filter (~/.lessfilter), more zip extensions, and rock/joliet iso handling
  (Portage version: 2.2_pre5)

Revision  Changes    Path
1.28                 sys-apps/less/files/lesspipe.sh

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-apps/less/files/lesspipe.sh?rev=1.28&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-apps/less/files/lesspipe.sh?rev=1.28&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-apps/less/files/lesspipe.sh?r1=1.27&r2=1.28

Index: lesspipe.sh
===================================================================
RCS file: /var/cvsroot/gentoo-x86/sys-apps/less/files/lesspipe.sh,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- lesspipe.sh	16 Mar 2008 13:01:51 -0000	1.27
+++ lesspipe.sh	16 Apr 2008 17:33:38 -0000	1.28
@@ -44,6 +44,11 @@
 
 	local DECOMPRESSOR=$(guesscompress "$match")
 
+	# User filters
+	if [[ -x ~/.lessfilter ]] ; then
+		~/.lessfilter "$1" && exit 0
+	fi
+
 	case "$match" in
 
 	### Doc files ###
@@ -97,7 +102,6 @@
 	*.bz2)        bzip2 -dc -- "$1" ;;
 	*.gz|*.z)     gzip -dc -- "$1"  ;;
 	*.lzma)       lzma -dc -- "$1" ;;
-	*.zip)        unzip -l "$1" ;;
 	*.rpm)        rpm -qpivl --changelog -- "$1" ;;
 	*.cpi|*.cpio) cpio -itv < "$1" ;;
 	*.ace)        unace l "$1" ;;
@@ -105,8 +109,8 @@
 	*.arj)        unarj l -- "$1" ;;
 	*.cab)        cabextract -l -- "$1" ;;
 	*.lha|*.lzh)  lha v "$1" ;;
-	*.zoo)        zoo -list "$1" ;;
-	*.7z)         7z l -- "$1" ;;
+	*.zoo)        zoo -list "$1" || unzoo -l "$1" ;;
+	*.7z)         7z l -- "$1" || 7za l -- "$1" ;;
 	*.a)          ar tv "$1" ;;
 	*.elf)        readelf -a -- "$1" ;;
 	*.so)         readelf -h -d -s -- "$1" ;;
@@ -114,8 +118,12 @@
 
 	*.rar|.r[0-9][0-9])  unrar l -- "$1" ;;
 
+	*.jar|*.war|*.ear|*.xpi|*.zip)
+		unzip -v "$1" || miniunzip -l "$1" || miniunz -l "$1" || zipinfo -v "$1"
+		;;
+
 	*.deb|*.udeb)
-		if type -p dpkg > /dev/null ; then
+		if type -P dpkg > /dev/null ; then
 			dpkg --info "$1"
 			dpkg --contents "$1"
 		else
@@ -134,9 +142,22 @@
 	*.mp3)        mp3info "$1" || id3info "$1" ;;
 	*.ogg)        ogginfo "$1" ;;
 	*.flac)       metaflac --list "$1" ;;
-	*.iso)        isoinfo -d -i "$1" ; isoinfo -l -i "$1" ;;
-	*.bin|*.cue)  cd-info --no-header --no-device-info "$1" ;;
 	*.torrent)    torrentinfo-console "$1" ;;
+	*.bin|*.cue|*.raw)
+		# not all .bin/.raw files are cd images, so fall back to hexdump
+		cd-info --no-header --no-device-info "$1" || lesspipe_file "$1"
+		;;
+	*.iso)
+		iso_info=$(isoinfo -d -i "$1")
+		echo "${iso_info}"
+		# Joliet output overrides Rock Ridge, so prefer the better Rock
+		case ${iso_info} in
+			*$'\n'"Rock Ridge"*) iso_opts="-R";;
+			*$'\n'"Joliet"*)     iso_opts="-J";;
+			*)                   iso_opts="";;
+		esac
+		isoinfo -l ${iso_opts} -i "$1"
+		;;
 
 	### Source code ###
 	*.awk|*.groff|*.java|*.js|*.m4|*.php|*.pl|*.pm|*.pod|*.sh|\
@@ -201,28 +222,35 @@
 
 if [[ -z $1 ]] ; then
 	echo "Usage: lesspipe.sh <file>"
-elif [[ $1 == "-V" ]] ; then
+elif [[ $1 == "-V" || $1 == "--version" ]] ; then
 	Id="cvsid"
-	cvsid="$Id: lesspipe.sh,v 1.27 2008/03/16 13:01:51 vapier Exp $"
+	cvsid="$Id: lesspipe.sh,v 1.28 2008/04/16 17:33:38 vapier Exp $"
 	cat <<-EOF
 		$cvsid
-		Copyright 2001-2006 Gentoo Foundation
+		Copyright 2001-2008 Gentoo Foundation
 		Mike Frysinger <vapier@g.o>
 		     (with plenty of ideas stolen from other projects/distros)
-		
-		
+
+
 	EOF
 	less -V
 elif [[ $1 == "-h" || $1 == "--help" ]] ; then
 	cat <<-EOF
 		lesspipe.sh: preproccess files before sending them to less
-		
+
 		Usage: lesspipe.sh <file>
-		
+
 		lesspipe.sh specific settings:
 		  LESSCOLOR env     - toggle colorizing of output
 		  LESSCOLORIZER env - program used to colorize output (default: code2color)
-		
+
+		You can create per-user filters as well by creating the executable file:
+		  ~/.lessfilter
+		One argument is passed to it: the file to display.
+
+		To use lesspipe.sh, simply add to your environment:
+		  export LESSOPEN="|lesspipe.sh %s"
+
 		Run 'less --help' or 'man less' for more info
 	EOF
 elif [[ -d $1 ]] ; then



-- 
gentoo-commits@g.o mailing list


Navigation:
Lists: gentoo-commits: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
gentoo-x86 commit in sys-apps/less/files: lesspipe.sh
Next by thread:
gentoo-x86 commit in sys-apps/less/files: lesspipe.sh
Previous by date:
gentoo-x86 commit in sys-apps/less: less-416.ebuild
Next by date:
gentoo-x86 commit in media-sound/cheesetracker: cheesetracker-0.9.9-r1.ebuild


Updated Jan 26, 2011

Summary: Archive of the gentoo-commits mailing list.

Donate to support our development efforts.

Copyright 2001-2013 Gentoo Foundation, Inc. Questions, Comments? Contact us.