#!/bin/sh # This is a preprocessor for 'less'. It is used when this environment # variable is set: LESSOPEN="|lesspipe.sh %s" lesspipe() { case "$1" in *.arj|*.ARJ) unarj l $1 2>/dev/null ; exit ;; *.deb|*.udeb) undeb -p $1 control.tar.gz | tar -xzO *control ; undeb -p $1 data.tar.gz | tar -tzv 2>/dev/null ; exit ;; *.lha|*.LHA|*.lzh|*.LZH) lha l $1 2>/dev/null ; exit ;; *.rar|*.RAR) unrar l -c- $1 2>/dev/null ; exit ;; *.rpm) unrpm < $1 | gzip -dc | cpio -tv 2>/dev/null ; exit ;; *.tar|*.TAR) tar tvvf $1 2>/dev/null ; exit ;; *.tgz|*.tar.gz|*.tar.Z|*.tar.z) tar tzvvf $1 2>/dev/null ; exit ;; *.tar.bz2) bzip2 -dc $1 | tar -tvvf - 2>/dev/null ; exit ;; *.slp) tar tvvf $1 --use-compress-program bzip2 2>/dev/null ; exit ;; *.bz2) bzip2 -dc $1 2>/dev/null ; exit ;; *.zip|*.ZIP) unzip -l $1 2>/dev/null ; exit ;; *.1|*.2|*.3|*.4|*.5|*.6|*.7|*.8|*.9|*.n|*.nro|*.man) FILE=`file -L $1 | cut -d' ' -f2` ; if [ "$FILE" = "troff" ]; then groff -Tascii -t -mandoc $1 ; exit ; fi ;; *.gz|*.Z|*.z) FILE=`file -z -L $1 | cut -d' ' -f2` ; if [ "$FILE" = "troff" ]; then gzip -dc $1 | groff -Tascii -t -mandoc ; exit else gzip -dc $1 2>/dev/null ; exit fi ;; *.lz) FILE=`file -z -L $1 | cut -d' ' -f2` ; if [ "$FILE" = "troff" ]; then lzip -dc $1 | groff -Tascii -t -mandoc ; exit else lzip -dc $1 2>/dev/null ; exit fi ;; *.xz) FILE=`file -z -L $1 | cut -d' ' -f2` ; if [ "$FILE" = "troff" ]; then xz -dc $1 | groff -Tascii -t -mandoc ; exit else xz -dc $1 2>/dev/null ; exit fi ;; esac TYPE=`file -z -L $1 | cut -d' ' -f2-` case $TYPE in GNU\ tar*) tar tvvf $1 ;; gzip*) gzip -dc $1 ;; compress\'d\ data*) gzip -dc $1 ;; LHa*) lha l $1 ;; RAR*) unrar l -c- $1 ;; RPM*) unrpm < $1 | gzip -dc | cpio -tv ;; current\ ar\ archive*) undeb -p $1 control.tar.gz | tar -xzO *control ; undeb -p $1 data.tar.gz | tar -tzv ;; ARJ*) unarj l $1 ;; Zip*) unzip -l $1 ;; troff*) groff -Tascii -t -mandoc $1 ;; ELF*) strings $1 ;; Linux/i386*) strings $1 ;; MS-DOS\ executable*) strings $1 ;; MS-Windows*) strings $1 ;; Win95\ executable*) strings $1 ;; *) unset lesspipe ;; esac } lesspipe $1 2>/dev/null