- Clean lesspipe.sh script
This commit is contained in:
parent
50e7a8994a
commit
f9e095f461
@ -72,6 +72,7 @@ ls -la $RPM_BUILD_ROOT/etc/profile.d
|
|||||||
rm -rf $RPM_BUILD_ROOT
|
rm -rf $RPM_BUILD_ROOT
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
- Clean lesspipe.sh script
|
||||||
- Split case for compressed and plain troff files
|
- Split case for compressed and plain troff files
|
||||||
- Add support for *.xz and *.lzma man pages
|
- Add support for *.xz and *.lzma man pages
|
||||||
Resolves: #676057
|
Resolves: #676057
|
||||||
|
57
lesspipe.sh
57
lesspipe.sh
@ -11,9 +11,19 @@
|
|||||||
# after the first one in the LESSOPEN environment variable:
|
# after the first one in the LESSOPEN environment variable:
|
||||||
# export LESSOPEN="||/usr/bin/lesspipe.sh %s"
|
# export LESSOPEN="||/usr/bin/lesspipe.sh %s"
|
||||||
|
|
||||||
lesspipe() {
|
if [ ! -e "$1" ] ; then
|
||||||
case "$1" in
|
exit 1
|
||||||
*.[1-9n].bz2|*.[1-9]x.bz2|*.man.bz2|*.[1-9n].[gx]z|*.[1-9]x.[gx]z|*.man.[gx]z|*.[1-9n].lzma|*.[1-9]x.lzma|*.man.lzma)
|
fi
|
||||||
|
|
||||||
|
if [ -d "$1" ] ; then
|
||||||
|
ls -alF -- "$1"
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec 2>/dev/null
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
*.[1-9n].bz2|*.[1-9]x.bz2|*.man.bz2|*.[1-9n].[gx]z|*.[1-9]x.[gx]z|*.man.[gx]z|*.[1-9n].lzma|*.[1-9]x.lzma|*.man.lzma)
|
||||||
case "$1" in
|
case "$1" in
|
||||||
*.gz) DECOMPRESSOR="gzip -dc" ;;
|
*.gz) DECOMPRESSOR="gzip -dc" ;;
|
||||||
*.bz2) DECOMPRESSOR="bzip2 -dc" ;;
|
*.bz2) DECOMPRESSOR="bzip2 -dc" ;;
|
||||||
@ -23,22 +33,22 @@ lesspipe() {
|
|||||||
$DECOMPRESSOR -- "$1" | man -l - | cat -s
|
$DECOMPRESSOR -- "$1" | man -l - | cat -s
|
||||||
exit $?
|
exit $?
|
||||||
fi ;;&
|
fi ;;&
|
||||||
*.[1-9n]|*.[1-9]x|*.man)
|
*.[1-9n]|*.[1-9]x|*.man)
|
||||||
if file "$1" | grep -q troff; then
|
if file "$1" | grep -q troff; then
|
||||||
man -l "$1" | cat -s
|
man -l "$1" | cat -s
|
||||||
exit $?
|
exit $?
|
||||||
fi ;;&
|
fi ;;&
|
||||||
*.tar) tar tvvf "$1" ;;
|
*.tar) tar tvvf "$1" ;;
|
||||||
*.tgz|*.tar.gz|*.tar.[zZ]) tar tzvvf "$1" ;;
|
*.tgz|*.tar.gz|*.tar.[zZ]) tar tzvvf "$1" ;;
|
||||||
*.tar.xz) tar Jtvvf "$1" ;;
|
*.tar.xz) tar Jtvvf "$1" ;;
|
||||||
*.xz|*.lzma) xz -dc -- "$1" ;;
|
*.xz|*.lzma) xz -dc -- "$1" ;;
|
||||||
*.tar.bz2|*.tbz2) bzip2 -dc -- "$1" | tar tvvf - ;;
|
*.tar.bz2|*.tbz2) bzip2 -dc -- "$1" | tar tvvf - ;;
|
||||||
*.[zZ]|*.gz) gzip -dc -- "$1" ;;
|
*.[zZ]|*.gz) gzip -dc -- "$1" ;;
|
||||||
*.bz2) bzip2 -dc -- "$1" ;;
|
*.bz2) bzip2 -dc -- "$1" ;;
|
||||||
*.zip|*.jar|*.nbm) zipinfo -- "$1" ;;
|
*.zip|*.jar|*.nbm) zipinfo -- "$1" ;;
|
||||||
*.rpm) rpm -qpivl --changelog -- "$1" ;;
|
*.rpm) rpm -qpivl --changelog -- "$1" ;;
|
||||||
*.cpi|*.cpio) cpio -itv < "$1" ;;
|
*.cpi|*.cpio) cpio -itv < "$1" ;;
|
||||||
*.gif|*.jpeg|*.jpg|*.pcd|*.png|*.tga|*.tiff|*.tif)
|
*.gif|*.jpeg|*.jpg|*.pcd|*.png|*.tga|*.tiff|*.tif)
|
||||||
if [ -x /usr/bin/identify ]; then
|
if [ -x /usr/bin/identify ]; then
|
||||||
identify "$1"
|
identify "$1"
|
||||||
elif [ -x /usr/bin/gm ]; then
|
elif [ -x /usr/bin/gm ]; then
|
||||||
@ -48,7 +58,7 @@ lesspipe() {
|
|||||||
echo "Install ImageMagick or GraphicsMagick to browse images"
|
echo "Install ImageMagick or GraphicsMagick to browse images"
|
||||||
exit 1
|
exit 1
|
||||||
fi ;;
|
fi ;;
|
||||||
*)
|
*)
|
||||||
if [ -x /usr/bin/file -a -x /usr/bin/iconv -a -x /usr/bin/cut ]; then
|
if [ -x /usr/bin/file -a -x /usr/bin/iconv -a -x /usr/bin/cut ]; then
|
||||||
case `file "$1"` in
|
case `file "$1"` in
|
||||||
*UTF-16*) conv='UTF-16' ;;
|
*UTF-16*) conv='UTF-16' ;;
|
||||||
@ -61,17 +71,6 @@ lesspipe() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
exit $?
|
exit $?
|
||||||
}
|
|
||||||
|
|
||||||
if [ ! -e "$1" ] ; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d "$1" ] ; then
|
|
||||||
ls -alF -- "$1"
|
|
||||||
exit $?
|
|
||||||
else
|
|
||||||
lesspipe "$1" 2> /dev/null
|
|
||||||
fi
|
|
||||||
|
Loading…
Reference in New Issue
Block a user