From f197286adf6bf97f4693eee3e4dcf38e029388ad Mon Sep 17 00:00:00 2001 From: "Vojtech Vitek (V-Teq)" Date: Mon, 14 Feb 2011 22:20:13 +0100 Subject: [PATCH] - Add support for *.xz and *.lzma man pages Split case for compressed and plain troff files Signed-off-by: Vojtech Vitek (V-Teq) --- less.spec | 3 +++ lesspipe.sh | 34 +++++++++++++++------------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/less.spec b/less.spec index a6147f0..fa8d3c3 100644 --- a/less.spec +++ b/less.spec @@ -71,6 +71,9 @@ ls -la $RPM_BUILD_ROOT/etc/profile.d rm -rf $RPM_BUILD_ROOT %changelog +- Split case for compressed and plain troff files +- Add support for *.xz and *.lzma man pages + Resolves: #676057 - Add support for reading UTF-16 and UTF-32 files Resolves: #638312 - Don't require correct exit status from LESSOPEN scripts until diff --git a/lesspipe.sh b/lesspipe.sh index 441207a..b12727f 100755 --- a/lesspipe.sh +++ b/lesspipe.sh @@ -13,32 +13,28 @@ lesspipe() { case "$1" in - *.[1-9n]|*.man|*.[1-9n].bz2|*.man.bz2|*.[1-9].gz|*.[1-9]x.gz|*.man.gz|*.[1-9].xz|*.[1-9]x.xz|*.man.xz) - case "$1" in - *.gz) DECOMPRESSOR="gzip -dc" ;; - *.bz2) DECOMPRESSOR="bzip2 -dc" ;; + *.[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 + *.gz) DECOMPRESSOR="gzip -dc" ;; + *.bz2) DECOMPRESSOR="bzip2 -dc" ;; + *.xz|*.lzma) DECOMPRESSOR="xz -dc" ;; esac - if [ ! -z "$DECOMPRESSOR" ] ; then - if $DECOMPRESSOR -- "$1" | file - | grep -q troff; then - if echo "$1" | grep -q ^/; then #absolute path - man -- "$1" | cat -s - else - man -- "./$1" | cat -s - fi - else - $DECOMPRESSOR -- "$1" - fi - else - exit 1 - fi ;; + if [ -n "$DECOMPRESSOR" ] && $DECOMPRESSOR -- "$1" | file - | grep -q troff; then + $DECOMPRESSOR -- "$1" | man -l - | cat -s + exit $? + fi ;;& + *.[1-9n]|*.[1-9]x|*.man) + if file "$1" | grep -q troff; then + man -l "$1" | cat -s + exit $? + fi ;;& *.tar) tar tvvf "$1" ;; *.tgz|*.tar.gz|*.tar.[zZ]) tar tzvvf "$1" ;; *.tar.xz) tar Jtvvf "$1" ;; - *.xz) xz -dc -- "$1" ;; + *.xz|*.lzma) xz -dc -- "$1" ;; *.tar.bz2|*.tbz2) bzip2 -dc -- "$1" | tar tvvf - ;; *.[zZ]|*.gz) gzip -dc -- "$1" ;; *.bz2) bzip2 -dc -- "$1" ;; - *.lzma) lzma -c -d -- "$1" ;; *.zip|*.jar|*.nbm) zipinfo -- "$1" ;; *.rpm) rpm -qpivl --changelog -- "$1" ;; *.cpi|*.cpio) cpio -itv < "$1" ;;