]>
Commit | Line | Data |
---|---|---|
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 | # | |
3d924463 | 23 | # $Id$' |
304efde1 MM |
24 | |
25 | # This is a preprocessor for 'less'. It is used when this environment | |
26 | # variable is set: LESSOPEN="|lesspipe.sh %s" | |
27 | ||
28 | lesspipe() { | |
c4d2a27d | 29 | case "$1" in |
688e2660 ER |
30 | # possible initrd images |
31 | *initrd-*.gz) | |
32 | if [[ $(file -z "$1" 2>/dev/null) == *cpio?archive* ]]; then | |
33 | echo "initrd contents:" | |
34 | local out=$(gzip -dc "$1" | cpio -itv --quiet) | |
35 | echo "$out" | |
36 | ||
37 | # also display linuxrc | |
38 | if [[ "$out" == *linuxrc* ]] ;then | |
39 | echo "" | |
40 | echo "/linuxrc program:" | |
41 | local tmp=$(mktemp -d) | |
42 | gzip -dc "$1" | (cd $tmp && cpio -dimu --quiet) | |
43 | cat $tmp/linuxrc | |
44 | rm -rf $tmp | |
45 | fi | |
46 | fi | |
47 | ;; | |
48 | ||
4e3efff9 | 49 | *.tar|*.phar) tar tvvf "$1" ;; |
ab8b7f2c | 50 | *.tar.lzma) lzma -dc -- "$1" | tar tvvf - ;; |
cdc788ed | 51 | *.a) ar tvf "$1" ;; |
effcca4c | 52 | *.tgz|*.tar.gz|*.tar.[Zz]) tar tzvvf "$1" ;; |
ed9cbcbe | 53 | *.tbz2|*.tar.bz2) bzip2 -dc -- "$1" | tar tvvf - ;; |
a26b485d | 54 | *.[Zz]|*.gz) gzip -dc -- "$1" ;; |
2c01bc31 | 55 | *.7z) 7z l "$1" ;; |
a26b485d ER |
56 | *.bz) bzip -dc -- "$1" ;; |
57 | *.bz2) bzip2 -dc -- "$1" ;; | |
dcd87d39 | 58 | *.lzma) lzma d -so -- "$1" ;; |
a020167b | 59 | *.zip|*.jar|*.xpi|*.pk3|*.skz) 7z l "$1" || unzip -l "$1" ;; |
effcca4c | 60 | *.rpm) rpm -qpivl --changelog -- "$1" ;; |
a039e48e | 61 | *.rar) unrar -p- l -- "$1" ;; |
effcca4c | 62 | *.cpi|*.cpio) cpio -itv < "$1" ;; |
1873db4f | 63 | *.cab|*.CAB) cabextract -l -- "$1" ;; |
dcea4001 | 64 | *.deb) dpkg -c "$1" ;; |
18a7c1be ER |
65 | # .war could be Zip (limewire) or tar.gz file (konqueror web archives) |
66 | *.war) 7z l "$1" || unzip -l "$1" || tar tzvvf "$1" ;; | |
4e3efff9 | 67 | # SSL certs |
a786c72f | 68 | *.csr) openssl req -noout -text -in "$1" ;; |
a9e3d45b | 69 | *.crl) openssl crl -noout -text -in "$1" ;; |
2944bb37 | 70 | *.crt) openssl x509 -noout -text -in "$1" ;; |
440eddcf ER |
71 | # gnupg armored files |
72 | *.asc) gpg --homedir=/dev/null "$1" 2>/dev/null ;; | |
4e3efff9 | 73 | # Possible manual pages |
4c335cf1 ER |
74 | *.1|*.2|*.3|*.4|*.5|*.6|*.7|*.8|*.9|*.l|*.n|*.man) |
75 | FILE=$(file -L "$1") # groff src | |
76 | FILE=$(echo $FILE | cut -d ' ' -f 2) | |
21fefdd5 | 77 | if [ "$FILE" = "troff" ]; then |
78 | groff -s -p -t -e -Tlatin1 -mandoc "$1" | |
4c335cf1 ER |
79 | fi |
80 | ;; | |
81 | *) | |
82 | # Check to see if binary, if so -- view with 'strings' | |
83 | # FILE=$(file -L "$1") | |
84 | esac | |
304efde1 MM |
85 | } |
86 | ||
2bad80b3 ER |
87 | if [ -d "$1" ] ; then |
88 | /bin/ls -alF -- "$1" | |
89 | else | |
90 | lesspipe "$1" 2> /dev/null | |
91 | fi |