commit 4d99be2d36f82080d98a81ec00e9ce60b9f6770b Author: overweight <5324761+overweight@user.noreply.gitee.com> Date: Mon Sep 30 10:54:43 2019 -0400 Package init diff --git a/less-394-time.patch b/less-394-time.patch new file mode 100644 index 0000000..85f52b3 --- /dev/null +++ b/less-394-time.patch @@ -0,0 +1,11 @@ +--- less-394/Makefile.in.time 2005-09-14 04:21:38.000000000 +0200 ++++ less-394/Makefile.in 2007-02-07 13:21:24.000000000 +0100 +@@ -6,7 +6,7 @@ + VPATH = @srcdir@ + + CC = @CC@ +-INSTALL = @INSTALL@ ++INSTALL = @INSTALL@ -p + INSTALL_PROGRAM = @INSTALL_PROGRAM@ + INSTALL_DATA = @INSTALL_DATA@ + diff --git a/less-418-fsync.patch b/less-418-fsync.patch new file mode 100644 index 0000000..5288fb2 --- /dev/null +++ b/less-418-fsync.patch @@ -0,0 +1,38 @@ +diff -ur less-418.orig/configure.ac less-418/configure.ac +--- less-418.orig/configure.ac 2008-12-22 07:10:44.000000000 -0500 ++++ less-418/configure.ac 2008-12-22 07:28:58.000000000 -0500 +@@ -203,6 +203,8 @@ + [Define HAVE_TIME_T if your system supports the "time_t" type.]) + AH_TEMPLATE([HAVE_STRERROR], + [Define HAVE_STRERROR if you have the strerror() function.]) ++AH_TEMPLATE([HAVE_FSYNC], ++ [Define HAVE_FSYNC if fsync() on a tty works.]) + AH_TEMPLATE([HAVE_FILENO], + [Define HAVE_FILENO if you have the fileno() macro.]) + AH_TEMPLATE([HAVE_ERRNO], +@@ -251,7 +253,7 @@ + + # Checks for library functions. + AC_TYPE_SIGNAL +-AC_CHECK_FUNCS([fsync popen _setjmp sigprocmask sigsetmask snprintf stat system fchmod realpath]) ++AC_CHECK_FUNCS([popen _setjmp sigprocmask sigsetmask snprintf stat system fchmod realpath]) + + # AC_CHECK_FUNCS may not work for inline functions, so test these separately. + AC_MSG_CHECKING(for memcpy) +@@ -298,6 +300,16 @@ + #endif], [static char *x; x = strerror(0);], + [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRERROR)], [AC_MSG_RESULT(no)]) + ++AC_MSG_CHECKING(for fsync) ++AC_TRY_RUN([ ++#include ++#include ++int main(void) ++{ ++ int fd = open("/dev/tty", O_RDWR); ++ return fsync(fd); ++}], [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FSYNC)], [AC_MSG_RESULT(no)]) ++ + AC_MSG_CHECKING(for sys_errlist) + AC_TRY_LINK(, [extern char *sys_errlist[]; static char **x; x = sys_errlist;], + [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYS_ERRLIST)], [AC_MSG_RESULT(no)]) diff --git a/less-436-help.patch b/less-436-help.patch new file mode 100644 index 0000000..09821c3 --- /dev/null +++ b/less-436-help.patch @@ -0,0 +1,50 @@ +diff --git a/help.c b/help.c +index 531aa16..0de6f0f 100644 +--- a/help.c ++++ b/help.c +@@ -119,7 +119,7 @@ constant char helpdata[] = { + ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','N','u','m','b','e','r',' ','o','f',' ','b','u','f','f','e','r','s','.','\n', + ' ',' ','-','B',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','a','u','t','o','-','b','u','f','f','e','r','s','\n', + ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','a','u','t','o','m','a','t','i','c','a','l','l','y',' ','a','l','l','o','c','a','t','e',' ','b','u','f','f','e','r','s',' ','f','o','r',' ','p','i','p','e','s','.','\n', +-' ',' ','-','c',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','c','l','e','a','r','-','s','c','r','e','e','n','\n', ++' ',' ','-','c',' ',' ','-','C',' ',' ','.','.','.','.',' ',' ','-','-','c','l','e','a','r','-','s','c','r','e','e','n',' ','-','-','C','L','E','A','R','-','S','C','R','E','E','N','\n', + ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','b','y',' ','c','l','e','a','r','i','n','g',' ','r','a','t','h','e','r',' ','t','h','a','n',' ','s','c','r','o','l','l','i','n','g','.','\n', + ' ',' ','-','d',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','d','u','m','b','\n', + ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','u','m','b',' ','t','e','r','m','i','n','a','l','.','\n', +@@ -151,8 +151,10 @@ constant char helpdata[] = { + ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','I','g','n','o','r','e',' ','t','h','e',' ','L','E','S','S','O','P','E','N',' ','e','n','v','i','r','o','n','m','e','n','t',' ','v','a','r','i','a','b','l','e','.','\n', + ' ',' ','-','m',' ',' ','-','M',' ',' ','.','.','.','.',' ',' ','-','-','l','o','n','g','-','p','r','o','m','p','t',' ',' ','-','-','L','O','N','G','-','P','R','O','M','P','T','\n', + ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','p','r','o','m','p','t',' ','s','t','y','l','e','.','\n', +-' ',' ','-','n',' ',' ','-','N',' ',' ','.','.','.','.',' ',' ','-','-','l','i','n','e','-','n','u','m','b','e','r','s',' ',' ','-','-','L','I','N','E','-','N','U','M','B','E','R','S','\n', ++' ',' ','-','n',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','l','i','n','e','-','n','u','m','b','e','r','s','\n', + ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','u','s','e',' ','l','i','n','e',' ','n','u','m','b','e','r','s','.','\n', ++' ',' ','-','N',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','L','I','N','E','-','N','U','M','B','E','R','S','\n', ++' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','U','s','e',' ','l','i','n','e',' ','n','u','m','b','e','r','s','.','\n', + ' ',' ','-','o',' ','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ',' ','.',' ',' ','-','-','l','o','g','-','f','i','l','e','=','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']','\n', + ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','o','p','y',' ','t','o',' ','l','o','g',' ','f','i','l','e',' ','(','s','t','a','n','d','a','r','d',' ','i','n','p','u','t',' ','o','n','l','y',')','.','\n', + ' ',' ','-','O',' ','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ',' ','.',' ',' ','-','-','L','O','G','-','F','I','L','E','=','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']','\n', +diff --git a/less.hlp b/less.hlp +index 15ece5a..186e409 100644 +--- a/less.hlp ++++ b/less.hlp +@@ -116,7 +116,7 @@ + Number of buffers. + -B ........ --auto-buffers + Don't automatically allocate buffers for pipes. +- -c ........ --clear-screen ++ -c -C .... --clear-screen --CLEAR-SCREEN + Repaint by clearing rather than scrolling. + -d ........ --dumb + Dumb terminal. +@@ -148,8 +148,10 @@ + Ignore the LESSOPEN environment variable. + -m -M .... --long-prompt --LONG-PROMPT + Set prompt style. +- -n -N .... --line-numbers --LINE-NUMBERS ++ -n ........ --line-numbers + Don't use line numbers. ++ -N ........ --LINE-NUMBERS ++ Use line numbers. + -o [_f_i_l_e] . --log-file=[_f_i_l_e] + Copy to log file (standard input only). + -O [_f_i_l_e] . --LOG-FILE=[_f_i_l_e] diff --git a/less-436-manpage-add-old-bot-option.patch b/less-436-manpage-add-old-bot-option.patch new file mode 100644 index 0000000..a3c76d7 --- /dev/null +++ b/less-436-manpage-add-old-bot-option.patch @@ -0,0 +1,13 @@ +--- less-436/less.nro.old-bot 2010-01-05 15:20:00.690985900 +0100 ++++ less-436/less.nro 2010-01-05 15:16:30.500112556 +0100 +@@ -555,6 +555,10 @@ This can cause + to run somewhat faster than the default. + .IP "\-G or \-\-HILITE-SEARCH" + The \-G option suppresses all highlighting of strings found by search commands. ++.IP "\-\-old-bot" ++Reverts to the old bottom of screen behavior. This can be sometimes ++desirable if the long lines are not wrapped correctly ++when reaching the bottom of the terminal, while scrolling forward. + .IP "\-h\fIn\fP or \-\-max-back-scroll=\fIn\fP" + Specifies a maximum number of lines to scroll backward. + If it is necessary to scroll backward more than \fIn\fP lines, diff --git a/less-458-less-filters-man.patch b/less-458-less-filters-man.patch new file mode 100644 index 0000000..a3ee61c --- /dev/null +++ b/less-458-less-filters-man.patch @@ -0,0 +1,22 @@ +diff -up less-466/less.nro.filters-man less-466/less.nro +--- less-466/less.nro.filters-man 2014-09-18 14:32:32.124111631 +0200 ++++ less-466/less.nro 2014-09-18 14:32:39.548177152 +0200 +@@ -1234,6 +1234,18 @@ Similarly, if the first two characters o + the input pipe is used on standard input as well as other files. + Again, in this case the dash is not considered to be part of + the input pipe command. ++.PP ++There are used following files to set up default preprocessor: ++.br ++ /etc/profile.d/less.sh ++.br ++ /etc/profile.d/less.csh ++.br ++These files set up /usr/bin/lesspipe.sh as a default filter. An user defined ++filter can be specified in ~/.lessfilter. This file should have an execute bit ++set and accept only one parameter, which represents a filename. If ++the user defined filter process the file, zero should be returned. Otherwise ++~/.lessfilter tries to handle the file. + + .SH "NATIONAL CHARACTER SETS" + There are three types of characters in the input file: diff --git a/less-458-lessecho-usage.patch b/less-458-lessecho-usage.patch new file mode 100644 index 0000000..14a7f37 --- /dev/null +++ b/less-458-lessecho-usage.patch @@ -0,0 +1,33 @@ +diff -upr less-458_orig/lessecho.c less-458_work/lessecho.c +--- less-458_orig/lessecho.c 2013-05-07 14:03:52.091104655 +0200 ++++ less-458_work/lessecho.c 2013-05-07 11:21:10.883991862 +0200 +@@ -41,7 +41,27 @@ static int num_metachars = 0; + pr_usage(VOID_PARAM) + { + fprintf(stderr, +- "usage: lessecho [-ox] [-cx] [-pn] [-dn] [-mx] [-nn] [-ex] [-fn] [-a] file ...\n"); ++ "usage: lessecho [-ox] [-cx] [-pn] [-dn] [-mx] [-nn] [-ex] [-fn] [-a] file ...\n\n"); ++ fprintf(stderr, ++ " -ox\t- specifies \"x\" to be the open quote character\n"); ++ fprintf(stderr, ++ " -cx\t- specifies \"x\" to be the close quote character\n"); ++ fprintf(stderr, ++ " -pn\t- specifies \"n\" to be the open quote character, as an integer\n"); ++ fprintf(stderr, ++ " -dn\t- specifies \"n\" to be the close quote character, as an integer\n"); ++ fprintf(stderr, ++ " -mx\t- specifies \"x\" to be a metachar\n"); ++ fprintf(stderr, ++ " -nn\t- specifies \"n\" to be a metachar, as an integer\n"); ++ fprintf(stderr, ++ " -ex\t- specifies \"x\" to be the escape char for metachars\n"); ++ fprintf(stderr, ++ " -fn\t- specifies \"n\" to be the escape char for metachars, as an integer\n"); ++ fprintf(stderr, ++ " -a\t- specifies that all arguments are to be quoted\n"); ++ fprintf(stderr, ++ " -?\t- prints this help\n"); + } + + static void + diff --git a/less-458-lesskey-usage.patch b/less-458-lesskey-usage.patch new file mode 100644 index 0000000..4015354 --- /dev/null +++ b/less-458-lesskey-usage.patch @@ -0,0 +1,20 @@ +diff -upr less-458_orig/lesskey.c less-458_work/lesskey.c +--- less-458_orig/lesskey.c 2013-05-07 14:03:52.062104533 +0200 ++++ less-458_work/lesskey.c 2013-05-07 11:21:10.881991855 +0200 +@@ -217,7 +217,15 @@ extern char version[]; + void + usage(VOID_PARAM) + { +- fprintf(stderr, "usage: lesskey [-o output] [input]\n"); ++ fprintf(stderr, "usage: lesskey [-o output] [input]\n\n"); ++ fprintf(stderr, ++ " -o output\t- specify output file, otherwise $HOME/.less is used\n"); ++ fprintf(stderr, ++ " -i input\t- specify input file, otherwise standard input is used\n"); ++ fprintf(stderr, ++ " -V\t\t- print lesskey version\n"); ++ fprintf(stderr, ++ " -h\t\t- print this help\n"); + exit(1); + } + diff --git a/less-458-old-bot-in-help.patch b/less-458-old-bot-in-help.patch new file mode 100644 index 0000000..7476dfc --- /dev/null +++ b/less-458-old-bot-in-help.patch @@ -0,0 +1,24 @@ +diff -up less-458/help.c.oldbothelp less-458/help.c +--- less-458/help.c.oldbothelp 2014-02-03 16:49:34.000000000 +0100 ++++ less-458/help.c 2014-02-03 16:50:17.202836595 +0100 +@@ -138,6 +138,8 @@ constant char helpdata[] = { + ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','H','i','g','h','l','i','g','h','t',' ','o','n','l','y',' ','l','a','s','t',' ','m','a','t','c','h',' ','f','o','r',' ','s','e','a','r','c','h','e','s','.','\n', + ' ',' ','-','G',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','H','I','L','I','T','E','-','S','E','A','R','C','H','\n', + ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','h','i','g','h','l','i','g','h','t',' ','a','n','y',' ','m','a','t','c','h','e','s',' ','f','o','r',' ','s','e','a','r','c','h','e','s','.','\n', ++' ',' ','-','-','o','l','d','-','b','o','t','\n', ++' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','v','e','r','t',' ','t','o',' ','t','h','e',' ','o','l','d',' ','b','o','t','t','o','m',' ','o','f',' ','s','c','r','e','e','n',' ','b','e','h','a','v','i','o','r','.','\n', + ' ',' ','-','h',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','m','a','x','-','b','a','c','k','-','s','c','r','o','l','l','=','[','_','\b','N',']','\n', + ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','B','a','c','k','w','a','r','d',' ','s','c','r','o','l','l',' ','l','i','m','i','t','.','\n', + ' ',' ','-','i',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','i','g','n','o','r','e','-','c','a','s','e','\n', +diff -up less-458/less.hlp.oldbothelp less-458/less.hlp +--- less-458/less.hlp.oldbothelp 2014-02-03 16:49:34.503555646 +0100 ++++ less-458/less.hlp 2014-02-03 16:49:34.507555673 +0100 +@@ -135,6 +135,8 @@ + Highlight only last match for searches. + -G ........ --HILITE-SEARCH + Don't highlight any matches for searches. ++ --old-bot ++ Revert to the old bottom of screen behavior. + -h [_N] .... --max-back-scroll=[_N] + Backward scroll limit. + -i ........ --ignore-case diff --git a/less-551.tar.gz b/less-551.tar.gz new file mode 100644 index 0000000..37c573e Binary files /dev/null and b/less-551.tar.gz differ diff --git a/less.csh b/less.csh new file mode 100644 index 0000000..d3c1f8e --- /dev/null +++ b/less.csh @@ -0,0 +1,15 @@ +# less initialization script (csh) + +# All less.*sh files should have the same semantics! + +# In case you are curious, the test for non-emptiness is not as easy as in +# Bourne shell. This "eval" construct is probably inspired by Stack +# Overflow question 13343392. +if ( $?LESSOPEN && { eval 'test ! -z "$LESSOPEN"' } ) then + : +else + if ( -x /usr/bin/lesspipe.sh ) then + # The '||' here is intentional, see rhbz#1254837. + setenv LESSOPEN "||/usr/bin/lesspipe.sh %s" + endif +endif diff --git a/less.sh b/less.sh new file mode 100644 index 0000000..189bbd2 --- /dev/null +++ b/less.sh @@ -0,0 +1,8 @@ +# less initialization script (sh) + +# All less.*sh files should have the same semantics! + +if [ -z "$LESSOPEN" ] && [ -x /usr/bin/lesspipe.sh ]; then + # The '||' here is intentional, see rhbz#1254837. + export LESSOPEN="||/usr/bin/lesspipe.sh %s" +fi diff --git a/less.spec b/less.spec new file mode 100644 index 0000000..b4d80ae --- /dev/null +++ b/less.spec @@ -0,0 +1,68 @@ +Name: less +Version: 551 +Release: 2 +Summary: Less is a pager that displays text files. +License: GPLv3+ or BSD +URL: http://www.greenwoodsoftware.com/less +Source0: http://www.greenwoodsoftware.com/less/%{name}-%{version}.tar.gz +Source1: lesspipe.sh +Source2: less.sh +Source3: less.csh +Patch0: less-394-time.patch +Patch1: less-418-fsync.patch +Patch2: less-436-manpage-add-old-bot-option.patch +Patch3: less-436-help.patch +Patch4: less-458-lessecho-usage.patch +Patch5: less-458-less-filters-man.patch +Patch6: less-458-lesskey-usage.patch +Patch7: less-458-old-bot-in-help.patch + +BuildRequires: git gcc make ncurses-devel autoconf automake libtool + +%description +Less is a pager. A pager is a program that displays text files. +Other pagers commonly in use are more and pg. Pagers are often +used in command-line environments like the Unix shell and the MS-DOS +command prompt to display files. + +Less is not an editor. You can't change the contents of the file +you're viewing. Less is not a windowing system. It doesn't have +fancy scroll bars or other GUI (graphical user interface) elements. + +%package_help + +%prep +%autosetup -n %{name}-%{version} -S git -p1 + +%build +rm -f ./configure +autoreconf -ivf +%configure +%make_build CFLAGS="%{optflags} -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" + +%install +%make_install +mkdir -p ${RPM_BUILD_ROOT}/etc/profile.d +install -p %{SOURCE1} ${RPM_BUILD_ROOT}/%{_bindir} +install -p -m 644 {%{SOURCE2},%{SOURCE3}} ${RPM_BUILD_ROOT}/etc/profile.d + + +%files +%defattr(-,root,root) +%license LICENSE COPYING +/etc/profile.d/* +%{_bindir}/less* + +%files help +%doc README NEWS INSTALL +%{_mandir}/man1/* + +%changelog +* Fri Sep 27 2019 yefei - 551-2 +- Type:enhancement +- ID:NA +- SUG:NA +- DESC: delete irrelevant comment + +* Tue Sep 10 2019 openEuler Buildteam - 551-1 +- Package Init diff --git a/lesspipe.sh b/lesspipe.sh new file mode 100755 index 0000000..ddd9480 --- /dev/null +++ b/lesspipe.sh @@ -0,0 +1,122 @@ +#!/bin/sh +# +# To use this filter with less, define LESSOPEN: +# export LESSOPEN="|/usr/bin/lesspipe.sh %s" +# +# The script should return zero if the output was valid and non-zero +# otherwise, so less could detect even a valid empty output +# (for example while uncompressing gzipped empty file). +# For backward-compatibility, this is not required by default. To turn +# this functionality there should be another vertical bar (|) straight +# after the first one in the LESSOPEN environment variable: +# export LESSOPEN="||/usr/bin/lesspipe.sh %s" + +if [ ! -e "$1" ] ; then + exit 1 +fi + +if [ -d "$1" ] ; then + ls -alF -- "$1" + exit $? +fi + +exec 2>/dev/null + +# Allow for user defined filters +if [ -x ~/.lessfilter ]; then + ~/.lessfilter "$1" + if [ $? -eq 0 ]; then + exit 0 + fi +fi + +manfilter () +{ + if test -x /usr/bin/man ; then + # See rhbz#1241543 for more info. Well, actually we firstly + # used 'man -l', then we switched to groff, and then we again + # switched back to 'man -l'. + /usr/bin/man -P /usr/bin/cat -l "$1" + elif test -x /usr/bin/groff; then + # This is from pre-rhbz#1241543-time. + groff -Tascii -mandoc "$1" | cat -s + else + echo "WARNING:" + echo "WARNING: to better show manual pages, install 'man-db' package" + echo "WARNING:" + cat "$1" + fi +} + +export MAN_KEEP_FORMATTING=1 + +case "$1" in +*.[1-9n].bz2|*.[1-9]x.bz2|*.man.bz2|*.[1-9n].[glx]z|*.[1-9]x.[glx]z|*.man.[glx]z|*.[1-9n].lzma|*.[1-9]x.lzma|*.man.lzma) + case "$1" in + *.gz) DECOMPRESSOR="gzip -dc" ;; + *.bz2) DECOMPRESSOR="bzip2 -dc" ;; + *.lz) DECOMPRESSOR="lzip -dc" ;; + *.xz|*.lzma) DECOMPRESSOR="xz -dc" ;; + esac + if [ -n "$DECOMPRESSOR" ] && $DECOMPRESSOR -- "$1" | file - | grep -q troff; then + $DECOMPRESSOR -- "$1" | manfilter - + exit $? + fi ;;& +*.[1-9n]|*.[1-9]x|*.man) + if file "$1" | grep -q troff; then + manfilter "$1" + exit $? + fi ;;& +*.tar) tar tvvf "$1"; exit $? ;; +*.tgz|*.tar.gz|*.tar.[zZ]) tar tzvvf "$1"; exit $? ;; +*.tar.xz) tar Jtvvf "$1"; exit $? ;; +*.xz|*.lzma) xz -dc -- "$1"; exit $? ;; +*.tar.lz) tar --lzip -tvvf "$1"; exit $? ;; +*.lz) lzip -dc -- "$1"; exit $? ;; +*.tar.bz2|*.tbz2) bzip2 -dc -- "$1" | tar tvvf -; exit $? ;; +*.[zZ]|*.gz) gzip -dc -- "$1"; exit $? ;; +*.bz2) bzip2 -dc -- "$1"; exit $? ;; +*.zip|*.jar|*.nbm) zipinfo -- "$1"; exit $? ;; +# --nomanifest -> rhbz#1450277 +*.rpm) rpm -qpivl --changelog --nomanifest -- "$1"; exit $? ;; +*.cpi|*.cpio) cpio -itv < "$1"; exit $? ;; +*.gpg) + if [ -x /usr/bin/gpg2 ]; then + gpg2 -d "$1" + exit $? + elif [ -x /usr/bin/gpg ]; then + gpg -d "$1" + exit $? + else + echo "No GnuPG available." + echo "Install gnupg2 or gnupg to show encrypted files." + exit 1 + fi ;; +*.gif|*.jpeg|*.jpg|*.pcd|*.png|*.tga|*.tiff|*.tif) + if [ -x /usr/bin/identify ]; then + identify "$1" + exit $? + elif [ -x /usr/bin/gm ]; then + gm identify "$1" + exit $? + else + echo "No identify available" + echo "Install ImageMagick or GraphicsMagick to browse images" + exit 1 + fi ;; +*) + if [ -x /usr/bin/file ] && [ -x /usr/bin/iconv ] && [ -x /usr/bin/cut ]; then + case `file -b "$1"` in + *UTF-16*) conv='UTF-16' ;; + *UTF-32*) conv='UTF-32' ;; + esac + if [ -n "$conv" ]; then + env=`echo $LANG | cut -d. -f2` + if [ -n "$env" -a "$conv" != "$env" ]; then + iconv -f $conv -t $env "$1" + exit $? + fi + fi + fi + exit 1 +esac