]> git.pld-linux.org Git - packages/less.git/blame - lesspipe.sh
- add *.tbz2
[packages/less.git] / lesspipe.sh
CommitLineData
304efde1
MM
1#!/bin/sh
2#
3# Copyright 1997, 1998 Patrick Volkerding, Moorhead, Minnesota USA
4# All rights reserved.
5#
6# Redistribution and use of this script, with or without modification, is
7# permitted provided that the following conditions are met:
8#
9# 1. Redistributions of this script must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11#
12# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
13# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
15# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
16# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
17# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
18# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
19# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
20# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
21# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22#
23
24# This is a preprocessor for 'less'. It is used when this environment
25# variable is set: LESSOPEN="|lesspipe.sh %s"
26
27lesspipe() {
c4d2a27d 28 case "$1" in
effcca4c
ER
29 *.tar) tar tvvf "$1" ;;
30 *.tgz|*.tar.gz|*.tar.[Zz]) tar tzvvf "$1" ;;
ed9cbcbe 31 *.tbz2|*.tar.bz2) bzip2 -dc -- "$1" | tar tvvf - ;;
a26b485d
ER
32 *.[Zz]|*.gz) gzip -dc -- "$1" ;;
33 *.bz) bzip -dc -- "$1" ;;
34 *.bz2) bzip2 -dc -- "$1" ;;
a786c72f 35 *.zip|*.jar) unzip -l "$1" ;;
effcca4c 36 *.rpm) rpm -qpivl --changelog -- "$1" ;;
e10c4aca 37 *.rar) unrar l -- "$1" ;;
effcca4c 38 *.cpi|*.cpio) cpio -itv < "$1" ;;
a786c72f
ER
39 # SSL CERTS
40 *.csr) openssl req -noout -text -in "$1" ;;
a9e3d45b 41 *.crl) openssl crl -noout -text -in "$1" ;;
21fefdd5 42 *.1|*.2|*.3|*.4|*.5|*.6|*.7|*.8|*.9|*.l|*.n|*.man) FILE=`file -L "$1"` ; # groff src
43 FILE=`echo $FILE | cut -d ' ' -f 2`
44 if [ "$FILE" = "troff" ]; then
45 groff -s -p -t -e -Tlatin1 -mandoc "$1"
46 fi ;;
47 *) FILE=`file -L "$1"` ; # Check to see if binary, if so -- view with 'strings'
304efde1
MM
48 esac
49}
50
2bad80b3
ER
51if [ -d "$1" ] ; then
52 /bin/ls -alF -- "$1"
53else
54 lesspipe "$1" 2> /dev/null
55fi
This page took 0.102931 seconds and 4 git commands to generate.