Hello community,

here is the log from the commit of package less.3873 for openSUSE:13.1:Update 
checked in at 2015-07-04 11:17:21
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:13.1:Update/less.3873 (Old)
 and      /work/SRC/openSUSE:13.1:Update/.less.3873.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "less.3873"

Changes:
--------
New Changes file:

--- /dev/null   2015-06-25 09:04:34.320025005 +0200
+++ /work/SRC/openSUSE:13.1:Update/.less.3873.new/less.changes  2015-07-04 
11:17:22.000000000 +0200
@@ -0,0 +1,771 @@
+-------------------------------------------------------------------
+Thu Jun 25 09:17:17 UTC 2015 - [email protected]
+
+- fix a crash in hilite_line (boo#915387)
+  * added less-fix_crash_in_hilite_line.patch 
+
+-------------------------------------------------------------------
+Fri Mar 13 16:17:36 UTC 2015 - [email protected]
+
+- add less-458-out_of_bounds_read.patch to fix an "out of bounds
+  read access in the UTF-8" vulnerability (bnc#921719),
+  (CVE-2014-9488)
+
+-------------------------------------------------------------------
+Wed Nov 13 11:23:59 CET 2013 - [email protected]
+
+- Fix lesspipe.sh for removing properly the leftover tmp files
+  when viewing patch files without colordiff (bnc#850225)
+
+-------------------------------------------------------------------
+Tue Jul 30 15:42:34 UTC 2013 - [email protected]
+
+- Update to version 458
+  * Fix Win32 attribute display bug.
+  * Fix display bug when using up/down arrow on the command line. 
+
+-------------------------------------------------------------------
+Mon May  6 20:20:03 UTC 2013 - [email protected]
+
+- make sure that -R or --RAW-CONTROL-CHARS is set in LESS
+  environment variable
+
+-------------------------------------------------------------------
+Mon May  6 13:23:33 UTC 2013 - [email protected]
+
+- add support for colordiff in lessopen.sh
+
+-------------------------------------------------------------------
+Wed Mar 20 16:31:12 UTC 2013 - [email protected]
+
+- Update to version 457
+  * Allow backslash escaping of metacharacters in LESS environment
+    variable if the --use-backslash option is set.
+  * Don't quit if syntax errors are found in command line options.
+  * Increase sizes of some internal buffers.
+  * Fix configure bug with --with-regex=none.
+  * Fix crash with "stty rows 0".
+
+-------------------------------------------------------------------
+Mon Nov 12 20:48:29 UTC 2012 - [email protected]
+
+- Update to version 456 
+  * Yet another bugfix in option string parser
+
+-------------------------------------------------------------------
+Tue Nov  6 11:24:25 UTC 2012 - [email protected]
+
+- Update to version 455 
+  * Bugfixes in buildsystem and option parser
+
+-------------------------------------------------------------------
+Sun Nov  4 21:06:26 UTC 2012 - [email protected]
+
+- Update to version 453
+  * Allow backslash escaping of metacharacters in LESS environment
+    variable.
+  * Don't quit if syntax errors are found in command line options.
+  * Increase sizes of some internal buffers.
+  * Fix configure bug with --with-regex=none.
+  * Fix crash with "stty rows 0".
+
+-------------------------------------------------------------------
+Tue Sep 25 07:48:44 UTC 2012 - [email protected]
+
+- Update to version 451
+    * Add ESC-F command to keep reading data until a pattern is
+    * found.
+
+    * Use exit code of LESSOPEN script if LESSOPEN starts with
+    * "||".
+
+    * When up/down arrow is used on the command line immediately
+    * after typing text, the next command starting with that text is
+      found.
+
+    * Add support for GNU regex.
+
+    * Add configure option --with-regex=none and fix compile
+    * errors when compiling with no regex library.
+
+    * Fix possible crashes caused by malformed LESSOPEN or 
+      LESSCLOSE variables.
+
+    * Fix bug highlighting text which is discontiguous in the
+    * file due to backspace processing.
+
+    * Fix bug in displaying status column when scrolling
+    * backwards with -J and -S in effect.
+- Remove speed patch.
+- Remove less-429-lessecho-man.patch
+
+-------------------------------------------------------------------
+Mon Dec  5 16:18:15 UTC 2011 - [email protected]
+
+- license update: GPL-3.0+ or BSD-2-Clause
+  The less license is a choice of either GPL-3.0+ or BSD-2-Clause (less
+  license). Use SPDX format
+
+-------------------------------------------------------------------
+Wed Nov 30 09:48:45 UTC 2011 - [email protected]
+
+- add automake as buildrequire to avoid implicit dependency
+
+-------------------------------------------------------------------
+Fri Nov  4 09:56:02 UTC 2011 - [email protected]
+
+- correctly recognize xz compressed data (bnc#728033)
+
+-------------------------------------------------------------------
+Thu Jun 16 08:26:41 UTC 2011 - [email protected]
+
+- Update to version 444
+  * Fix bug in unget handling that can cause strange effects 
+    on the command line.
+  * Remove vestiges of obsolete -l option that can cause a crash.
+
+-------------------------------------------------------------------
+Thu May 26 17:08:36 UTC 2011 - [email protected]
+
+- bump version 443
+  * Change search behavior such that when a search is given an explicit 
pattern,
+    the entire displayed screen is included in the search and not just the
+    portion after the target line.
+  * Add -A option to change search behavior to the old way: only the portion of
+    the screen after the target line is searched.
+  * Add %F formatting to prompt strings, replaced by the last component of the
+    input file.
+  * Control-G while editing a command exits the command.
+  * Less now exits with status 2 if control-C is pressed and -K is in effect.
+  * Fix "ungetc overflow" when passing long commands via the -p option.
+  * Fix bug in using line filtering via the & command in combination with -i 
and
+    -I.
+  * Fix bug in handling negative arguments to the -j option.
+  * Fix bug in handling %t in prompt strings.
+  * Improve handling of long option names.
+  * Improve percentage calculation for very large files.
+- remove mouse patch because
+  * conflicting short opt -A since version 443, see changes above
+  * was working for xterm only so probably nobody is using it
+
+-------------------------------------------------------------------
+Thu May 26 12:29:52 UTC 2011 - [email protected]
+
+- lessopen.sh, support xz compressed data
+
+-------------------------------------------------------------------
+Mon Jun 28 06:38:35 UTC 2010 - [email protected]
+
+- use %_smp_mflags
+
+-------------------------------------------------------------------
+Thu Oct  1 14:18:12 UTC 2009 - [email protected]
+
+- add support for listing directories to lessopen.sh (bnc#537646)
+  - thanks to Dimitar Pashov for the patch
+
+-------------------------------------------------------------------
+Mon Jul 27 10:09:45 CEST 2009 - [email protected]
+
+- bump version to less-436 (final)
+  * no code changed
+
+-------------------------------------------------------------------
+Fri Jul 10 10:24:54 CEST 2009 - [email protected]
+
+- update to less-436beta
+  * Fixes a few search and filter bugs.
+
+-------------------------------------------------------------------
+Tue Jul  7 16:01:30 CEST 2009 - [email protected]
+
+- update to less-434beta
+  * Don't pass "-" to non-pipe LESSOPEN unless it starts with "-".
+  * Allow a fraction as the argument to the -# (--shift) option.
+  * Fix highlight bug when underlined/overstruck text matches at end of line.
+  * Fix non-regex searches with ctrl-R.
+
+-------------------------------------------------------------------
+Wed Jun  3 15:46:47 CEST 2009 - [email protected]
+
+- update to less-429
+  * LESSOPEN pipe will now be used on standard input, if the LESSOPEN
+    environment variable begins with "|-".
+  * The -D option with one number now means use the normal background color.
+  * Fix non-ANSI-compliant code that caused problems with some compilers.
+  * Fix binary file detection in UTF-8 mode.
+  * Fix display problems with long lines on "ignaw" terminals.
++++ 574 more lines (skipped)
++++ between /dev/null
++++ and /work/SRC/openSUSE:13.1:Update/.less.3873.new/less.changes

New:
----
  README.SuSE
  less-429-more.patch
  less-429-save_line_position.patch
  less-429-shell.patch
  less-429-strict_aliasing.patch
  less-429-terminate.patch
  less-429-widechars.patch
  less-458-out_of_bounds_read.patch
  less-458.tar.gz
  less-fix_crash_in_hilite_line.patch
  less.changes
  less.spec
  lessclose.sh
  lesskey.src
  lessopen.sh

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ less.spec ++++++
#
# spec file for package less
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           less
BuildRequires:  automake
BuildRequires:  ncurses-devel
Obsoletes:      jless
Provides:       jless
Provides:       normal-less
Requires:       file
Version:        458
Release:        0
Summary:        Text File Browser and Pager Similar to more
License:        GPL-3.0+ or BSD-2-Clause
Group:          Productivity/Text/Utilities
Url:            http://www.greenwoodsoftware.com/less/
Source:         http://www.greenwoodsoftware.com/less/less-%{version}.tar.gz
Source1:        README.SuSE
Source2:        lessopen.sh
Source3:        lessclose.sh
Source4:        lesskey.src
Patch22:        %{name}-429-strict_aliasing.patch
Patch24:        %{name}-429-terminate.patch
Patch25:        %{name}-429-widechars.patch
Patch26:        %{name}-429-shell.patch
Patch27:        %{name}-429-save_line_position.patch
Patch28:        %{name}-429-more.patch
# PATCH-FIX-UPSTREAM bnc#921719 [email protected] -- security fix of an out 
of bound read access in the UTF-8
Patch29:        less-458-out_of_bounds_read.patch
# PATCH-FIX-UPSTREAM fix crash in nomatch search
Patch30:        less-fix_crash_in_hilite_line.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
less is a text file browser and pager similar to more. It allows
backward as well as forward movement within a file. Also, less does not
have to read the entire input file before starting. It is possible to
start an editor at any time from within less.

%prep
%setup -q
%patch22
%patch24
%patch25
%patch26
%patch27
%patch28
%patch29 -p1
%patch30 -p1
#
# the ./configure script is not writable for the normal user
# rather fix permissions for all files
chmod u+w *
#
cp %{S:1} %{S:2} %{S:3} %{S:4} .

%build
autoreconf -fiv
%configure --with-pic
#
# regenerate help.c because less.hlp was patched
make mkhelp
./mkhelp <less.hlp >help.c
#
# build less
make %{?_smp_mflags}

%install
make DESTDIR=$RPM_BUILD_ROOT/ install
#
# lesskey
install -m 755 -d $RPM_BUILD_ROOT/%{_sysconfdir}
install -m 644 lesskey.src $RPM_BUILD_ROOT/%{_sysconfdir}/lesskey
$RPM_BUILD_ROOT%{_bindir}/lesskey -o $RPM_BUILD_ROOT%{_sysconfdir}/lesskey.bin 
$RPM_BUILD_ROOT%{_sysconfdir}/lesskey
#
# preprocessor
install -m 755 lessopen.sh lessclose.sh $RPM_BUILD_ROOT/%{_bindir}
%__chmod -x LICENSE COPYING NEWS README.SuSE

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-, root, root)
%doc LICENSE COPYING NEWS README.SuSE
%doc %{_mandir}/*/*
%config %{_sysconfdir}/*
%{_bindir}/*

%changelog
++++++ README.SuSE ++++++
Dear user,

the 'less' application, thanks to its preprocessor, is able to show even binary
formats using calls to external commands. Since not every user finds this
feature plausible, you have the opportunity to customize behavior of 'less'
using the environment variable LESS_ADVANCED_PREPROCESSOR. By default, it's set
to "no" in /etc/profile -- thus if you require less to handle binary formats,
set this in your startup scripts:

export LESS_ADVANCED_PREPROCESSOR="yes"

Remark for experienced users:
If you had already set this switch and want to temporarily override it, you can
force 'less' to read a file from its standard input instead, e.g.:

less < dumb.ps

will show the source PostScript, and not the "rendered" result.
++++++ less-429-more.patch ++++++
--- option.c
+++ option.c
@@ -134,6 +134,10 @@
                        s--;
                        optc = 'z';
                        break;
+               case 'l':
+                       if (less_is_more)
+                               continue;
+                       break;
                case 'n':
                        if (less_is_more)
                                optc = 'z';
++++++ less-429-save_line_position.patch ++++++
---
 line.c |   31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

Index: line.c
===================================================================
--- line.c.orig 2009-06-30 21:27:09.000000000 +0200
+++ line.c      2009-07-07 15:39:00.000000000 +0200
@@ -66,6 +66,25 @@ static int mbc_buf_len = 0;
 static int mbc_buf_index = 0;
 static POSITION mbc_pos;
 
+
+
+/* Following define alters the "-r" switch to not throw
+ * away location information, but keep location as well
+ * as "possible" (currently only interpreting location escape
+ * sequences
+ *
+ * This benefits the user who may be operating with "-r" but
+ * is still displaying predominantly "normal" spacing characters
+ * (especially single, 8-bit characters that print "normally"
+ * but might otherwise be "undisplayable" in non "-r" mode.
+ *
+ * This is especially true using extended European characters
+ * that might be present in UTF-8 docs (among others);
+ *                                     - [email protected]
+ */
+#define THROW_AWAY_LOCATION 0
+
+
 /*
  * Initialize from environment variables.
  */
@@ -617,7 +636,11 @@ store_char(ch, a, rep, pos)
                w = pwidth(ch, a, prev_ch);
        }
 
-       if (ctldisp != OPT_ON && column + w + attr_ewidth(a) > sc_width)
+       if (
+#if THROW_AWAY_LOCATION
+                       ctldisp != OPT_ON &&
+#endif
+                       column + w + attr_ewidth(a) > sc_width)
                /*
                 * Won't fit on screen.
                 */
@@ -949,7 +972,11 @@ do_append(ch, rep, pos)
                {
                        STORE_PRCHAR((char) ch, pos);
                }
-       } else if (utf_mode && ctldisp != OPT_ON && is_ubin_char(ch))
+       } else if (utf_mode &&
+#if THROW_AWAY_LOCATION
+                       ctldisp != OPT_ON &&
+#endif
+                       is_ubin_char(ch))
        {
                char *s;
 
++++++ less-429-shell.patch ++++++
Index: filename.c
===================================================================
--- filename.c.orig     2009-07-06 22:52:23.000000000 +0200
+++ filename.c  2009-07-10 10:23:12.000000000 +0200
@@ -577,7 +577,7 @@ shellcmd(cmd)
 #if HAVE_SHELL
        char *shell;
 
-       shell = lgetenv("SHELL");
+       shell = lgetenv("LESSSHELL");
        if (shell != NULL && *shell != '\0')
        {
                char *scmd;
Index: less.hlp
===================================================================
--- less.hlp.orig       2009-07-10 10:23:07.000000000 +0200
+++ less.hlp    2009-07-10 10:23:12.000000000 +0200
@@ -95,7 +95,7 @@
   ___<_n_a_m_e_>             Display the setting of an option, by name.
   +_c_m_d                 Execute the less cmd each time a new file is 
examined.
 
-  !_c_o_m_m_a_n_d             Execute the shell command with $SHELL.
+  !_c_o_m_m_a_n_d             Execute the shell command with $LESSSHELL.
   |XX_c_o_m_m_a_n_d            Pipe file between current pos & mark 
XX to shell command.
   v                    Edit the current file with $VISUAL or $EDITOR.
   V                    Print version number of "less".
Index: less.nro
===================================================================
--- less.nro.orig       2009-07-10 10:23:07.000000000 +0200
+++ less.nro    2009-07-10 10:23:12.000000000 +0200
@@ -395,7 +395,7 @@ current file.
 A pound sign (#) is replaced by the name of the previously examined file.
 "!!" repeats the last shell command.
 "!" with no shell command simply invokes a shell.
-On Unix systems, the shell is taken from the environment variable SHELL,
+On Unix systems, the shell is taken from the environment variable LESSSHELL,
 or defaults to "sh".
 On MS-DOS and OS/2 systems, the shell is the normal command processor.
 .IP "| <m> shell-command"
@@ -1667,7 +1667,7 @@ LINES and COLUMNS environment variables.
 .IP PATH
 User's search path (used to find a lesskey file 
 on MS-DOS and OS/2 systems).
-.IP SHELL
+.IP LESSSHELL
 The shell used to execute the ! command, as well as to expand filenames.
 .IP TERM
 The type of terminal on which
Index: lsystem.c
===================================================================
--- lsystem.c.orig      2009-07-06 22:52:23.000000000 +0200
+++ lsystem.c   2009-07-10 10:23:12.000000000 +0200
@@ -129,7 +129,7 @@ lsystem(cmd, donemsg)
         */
 #if HAVE_SHELL
        p = NULL;
-       if ((shell = lgetenv("SHELL")) != NULL && *shell != '\0')
+       if ((shell = lgetenv("LESSSHELL")) != NULL && *shell != '\0')
        {
                if (*cmd == '\0')
                        p = save(shell);
++++++ less-429-strict_aliasing.patch ++++++
The strict aliasing rules are broken without this patch becase there
is defined a pointer to the "struct tag" and the structure is defined
later.
================================================================================
--- tags.c
+++ tags.c
@@ -63,8 +63,6 @@
        struct tag *tl_first;
        struct tag *tl_last;
 };
-#define TAG_END  ((struct tag *) &taglist)
-static struct taglist taglist = { TAG_END, TAG_END };
 struct tag {
        struct tag *next, *prev; /* List links */
        char *tag_file;         /* Source file containing the tag */
@@ -72,6 +70,8 @@
        char *tag_pattern;      /* Pattern used to find the tag */
        char tag_endline;       /* True if the pattern includes '$' */
 };
+#define TAG_END  ((struct tag *) &taglist)
+static struct taglist taglist = { TAG_END, TAG_END };
 static struct tag *curtag;
 
 #define TAG_INS(tp) \
++++++ less-429-terminate.patch ++++++
Index: edit.c
===================================================================
--- edit.c.orig 2009-03-30 21:45:51.000000000 +0200
+++ edit.c      2009-06-03 15:20:08.000000000 +0200
@@ -152,7 +152,7 @@ back_textlist(tlist, prev)
 /*
  * Close the current input file.
  */
-       static void
+       public void
 close_file()
 {
        struct scrpos scrpos;
Index: funcs.h
===================================================================
--- funcs.h.orig        2009-06-03 15:17:47.000000000 +0200
+++ funcs.h     2009-06-03 15:20:08.000000000 +0200
@@ -97,6 +97,7 @@
        public void init_textlist ();
        public char * forw_textlist ();
        public char * back_textlist ();
+       public void close_file ();
        public int edit ();
        public int edit_ifile ();
        public int edit_list ();
Index: signal.c
===================================================================
--- signal.c.orig       2009-03-30 22:35:36.000000000 +0200
+++ signal.c    2009-06-03 15:20:08.000000000 +0200
@@ -37,6 +37,35 @@ extern int quit_on_intr;
 extern long jump_sline_fraction;
 
 /*
+ * Terminate signal handler.
+ */
+       static RETSIGTYPE
+terminate(type)
+       int type;
+{
+       /*
+        * run $LESSCLOSE if needed
+        */
+       close_file();
+
+       /*
+        * Clean up the terminal.
+        */
+#ifdef SIGTTOU
+       LSIGNAL(SIGTTOU, SIG_IGN);
+#endif
+       clear_bot();
+       deinit();
+       flush();
+       raw_mode(0);
+#ifdef SIGTTOU
+       LSIGNAL(SIGTTOU, SIG_DFL);
+#endif
+       LSIGNAL(SIGTERM, SIG_DFL);
+       kill(getpid(), SIGTERM);
+}
+
+/*
  * Interrupt signal handler.
  */
        /* ARGSUSED*/
@@ -147,6 +176,7 @@ init_signals(on)
                 * Set signal handlers.
                 */
                (void) LSIGNAL(SIGINT, u_interrupt);
+               (void) LSIGNAL(SIGTERM, terminate);
 #if MSDOS_COMPILER==WIN32C
                SetConsoleCtrlHandler(wbreak_handler, TRUE);
 #endif
@@ -168,6 +198,7 @@ init_signals(on)
                 * Restore signals to defaults.
                 */
                (void) LSIGNAL(SIGINT, SIG_DFL);
+               (void) LSIGNAL(SIGTERM, SIG_DFL);
 #if MSDOS_COMPILER==WIN32C
                SetConsoleCtrlHandler(wbreak_handler, FALSE);
 #endif
++++++ less-429-widechars.patch ++++++
Index: cmdbuf.c
===================================================================
--- cmdbuf.c.orig       2009-06-03 15:16:21.000000000 +0200
+++ cmdbuf.c    2009-06-03 15:20:52.000000000 +0200
@@ -246,7 +246,9 @@ cmd_step_common(p, ch, len, pwidth, bswi
                                                        ?       2
                                                        :       1;
                                        if (bswidth != NULL)
-                                               *bswidth = 1;
+                                               *bswidth = is_wide_char(ch)
+                                                       ?       2
+                                                       :       1;
                                }
                        }
                }
++++++ less-458-out_of_bounds_read.patch ++++++
Index: less-458/line.c
===================================================================
--- less-458.orig/line.c
+++ less-458/line.c
@@ -828,7 +828,7 @@ pappend(c, pos)
                        mbc_buf[mbc_buf_index++] = c;
                        if (mbc_buf_index < mbc_buf_len)
                                return (0);
-                       if (is_utf8_well_formed(mbc_buf))
+                       if (is_utf8_well_formed(mbc_buf, mbc_buf_index))
                                r = do_append(get_wchar(mbc_buf), mbc_buf, 
mbc_pos);
                        else
                                /* Complete, but not shortest form, sequence. */
++++++ less-fix_crash_in_hilite_line.patch ++++++
Index: less-458/pattern.c
===================================================================
--- less-458.orig/pattern.c     2013-04-04 18:55:06.000000000 +0200
+++ less-458/pattern.c  2015-06-25 11:06:56.681087046 +0200
@@ -277,6 +277,7 @@ match_pattern(pattern, tpattern, line, l
        struct regexp *spattern = (struct regexp *) pattern;
 #endif
 
+       *sp = *ep = NULL;
 #if NO_REGEX
        search_type |= SRCH_NO_REGEX;
 #endif
++++++ lessclose.sh ++++++
#!/bin/sh
#
# Copyright (c) 2001 SuSE GmbH, Nuernberg, Germany
# Copyright (c) 2002 SuSE Linux AG, Nuernberg, Germany
#
# Author: Vladim�r Linek <[email protected]>
#
# Postprocessor for 'less'.
# Use with environment variable:  LESSCLOSE="lessclose.sh %s %s"
#

test "$1" = "$2" || rm -f "$2"
++++++ lesskey.src ++++++
#command
\e[A    back-line     
\e[B    forw-line      
\eO5A   back-line
\eO5B   forw-line
\eO5C   right-scroll
\eO5D   left-scroll
\e[6~   forw-scroll
\e[5~   back-scroll 
\177    back-screen
^H      back-screen
\e[3~   back-screen
\e[3;5~ back-screen
\e[2~   visual
\e[2;5~ visual
\e[1~   goto-line
\eOH    goto-line
\eO5H   goto-line
\e[4~   goto-end
\eOF    goto-end
\eO5F   goto-end
\eOM    forw-line
#line-edit
\eO5A   up
\eO5B   down
\eO5C   right
\eO5D   left
\177    backspace
^H      backspace
\e[3~   delete
\e[3;5~ delete
\e[1~   home
\eOH    home
\eO5H   home
\e[4~   end
\eOF    end
\eO5F   end
\e[5~   up
\e[6~   down
\e[5;5~ up
\e[6;5~ down
\e[2~   insert
\e[2;5~ insert
\e[E    insert
\e[G    insert
\eOE    insert
\eOo    insert :
\eOj    insert *
\eOm    insert -
\eOk    insert +
\eOl    insert ,
\eOM    insert 
\eOw    insert 7
\eOx    insert 8
\eOy    insert 9
\eOt    insert 4
\eOu    insert 5
\eOv    insert 6
\eOq    insert 1
\eOr    insert 2
\eOs    insert 3
\eOp    insert 0
\eOn    insert .
#env
LESSBINFMT=*s\%o
++++++ lessopen.sh ++++++
#!/bin/bash
#
# Copyright (c) 2001 SuSE GmbH, Nuernberg, Germany
# Copyright (c) 2002 SuSE Linux AG, Nuernberg, Germany
#
# Author: Vladimir Linek <[email protected]>
# Support for directory listing by Dimitar Pashov <[email protected]>
#
# Preprocessor for 'less'.
# Use with environment variable:  LESSOPEN="lessopen.sh %s"

# the following hack does not break anything but helps to view file whose name
# begins with a "-" or "+" with names
if echo "$1" | grep -q ^/; then
  # absolute path
  SRC="$1"
else
  # relative path
  SRC="./$1"
fi
  
NAME="${SRC##*/}"

[ ! -r "$SRC" ] && exit 1

TMPF=$(mktemp /tmp/less.XXXXXX) || exit 1
TMPF_pre=$(mktemp /tmp/less.XXXXXX) || { rm -f "$TMPF"; exit 1; }

case $LANG in
    ja*)
    GROFF_DEVICE=nippon
    ;;
    *)
    GROFF_DEVICE=latin1
    ;;
esac

CMD=
type=`file -L "$SRC"`
case ${type#"$SRC": } in
        *"gzip compressed data"*|\
        *"compress'd data"*|\
        *"packed data"*)
                CMD="gzip -dc" ;;
        *"Zip archive data"*)
                CMD="unzip -v" ;;
        *"bzip"*" compressed data"*)
                CMD="bzip2 -dc" ;;
        *"xz compressed data"*|\
        *"XZ compressed data"*)
                CMD="xz -dc" ;;
        *)
                rm -f "$TMPF_pre"
                TMPF_pre="$SRC" ;;
esac

test -n "$CMD" && $CMD "$SRC" >"$TMPF_pre" 2>/dev/null

        type=`file -L "$TMPF_pre"`
        case ${type#"$TMPF_pre": } in
                *tar\ archive*)
                        if [ -x "`which tar 2>/dev/null`" ]; then
                        tar tvvf "$TMPF_pre" >"$TMPF" 2>/dev/null
                        else echo "tar is not available for preprocessing" 
1>&2; rm -f "$TMPF"; TMPF="$TMPF_pre"; fi
                        ;;
                *Microsoft\ Cabinet\ *\ data*)
                        if [ -x "`which cabextract 2>/dev/null`" ]; then
                        cabextract -l "$TMPF_pre" >"$TMPF" 2>/dev/null
                        else echo "cabextract is not available for 
preprocessing" 1>&2; rm -f "$TMPF"; TMPF="$TMPF_pre"; fi
                        ;;
                *RPM*)
                        if [ -x "`which rpm 2>/dev/null`" ]; then
                        (echo -e "=============================== Information 
====================================\n";
                        rpm -qip "\"$TMPF_pre\"";
                        echo -e "\n\n================================= 
Changelog (head) =============================\n";
                        rpm -qp --changelog "\"$TMPF_pre\"" | head -n 16
                        echo -e "\n\n================================= Content 
======================================\n";
                        rpm -qlp "\"$TMPF_pre\""
                        ) >"$TMPF" 2>/dev/null
                        else echo "rpm is not available for preprocessing" 
1>&2; rm -f "$TMPF"; TMPF="$TMPF_pre"; fi
                        ;;
                *DVI*)
                        if [ -x "`which dvi2tty 2>/dev/null`" ]; then
                          if [ "${TMPF_pre%.dvi}" != "$TMPF_pre" ] ; then
                             dvi2tty -q "$TMPF_pre" >"$TMPF" 2>/dev/null
                          else echo "dvi2tty requires an input file name with 
the suffix .dvi" 1>&2; rm -f "$TMPF"; TMPF="$TMPF_pre" ; fi
                        else echo "dvi2tty is not available for preprocessing" 
1>&2; rm -f "$TMPF"; TMPF="$TMPF_pre"; fi
                        ;;
                *PDF*)
                        if [ -x "`which pdftotext 2>/dev/null`" ]; then
                        pdftotext "$TMPF_pre" "$TMPF" 2>/dev/null
                        else echo "pdftotext is not available for 
preprocessing" 1>&2; rm -f "$TMPF"; TMPF="$TMPF_pre"; fi
                        ;;
                *Debian\ binary\ package*)
                        if [ -x "`which dpkg-deb 2>/dev/null`" ]; then
                        dpkg-deb -c "$TMPF_pre" >"$TMPF" 2>/dev/null
                        else echo "dpkg-deb is not available for preprocessing" 
1>&2; rm -f "$TMPF"; TMPF="$TMPF_pre"; fi
                        ;;
                *\ ar\ archive*)
                        if [ -x "`which nm 2>/dev/null`" ]; then
                        nm "$TMPF_pre" >"$TMPF" 2>/dev/null
                        else echo "nm is not available for preprocessing" 1>&2; 
rm -f "$TMPF"; TMPF="$TMPF_pre"; fi
                        ;;
                *directory*)
                        # assuming ls is always available
                        ls -lh "$TMPF_pre" >"$TMPF" 2>/dev/null
                        ;;
                *diff\ output*)
                        # I haven't found way, to set less -R from this script
                        # so check, if '-R' or '--RAW-CONTROL-CHARS' is set in 
environment
                        R_NOT_SET=true
                        for i in $LESS; do
                                if [ "${i:0:1}" = "-" ]; then
                                        if [ "${i:1:1}" = "-" ]; then
                                                if [ "$i" = --RAW-CONTROL-CHARS 
]; then
                                                        R_NOT_SET=false
                                                        break
                                                else
                                                        continue
                                                fi
                                        else
                                                for j in `seq 1 $((${#i} - 1 
))`; do
                                                        if [ "${i:j:1}" = R ]; 
then
                                                                R_NOT_SET=false
                                                                break
                                                        fi
                                                done
                                        fi
                                fi
                        done
                        # if we have -R and colordiff, we can continue
                        if [ $R_NOT_SET = false ] && \
                                [ -x "`which colordiff 2>/dev/null`" ]; then
                        colordiff < "$TMPF_pre" | cat > "$TMPF" 2>/dev/null
                        else rm -f "$TMPF"; TMPF="$TMPF_pre"; fi
                        ;;
                *)
                        if [ "$LESS_ADVANCED_PREPROCESSOR" = "yes" ]; then
                                case ${type#"$TMPF_pre": } in
                                        *troff*)
                                                if [ -x "`which groff 
2>/dev/null`" ]; then
                                                case "$NAME" in
                                                        
*.[1-9nxp]*|*.man|*.[1-9nxp]*.*|*.man.*)
                                                                groff -s -p -t 
-e -T$GROFF_DEVICE -mandoc "$TMPF_pre" >"$TMPF" 2>/dev/null ;;
                                                        *.ms|*.ms.*)
                                                                groff 
-T$GROFF_DEVICE -ms "$TMPF_pre" >"$TMPF" 2>/dev/null ;;
                                                        *.me|*.me.*)
                                                                groff 
-T$GROFF_DEVICE -me "$TMPF_pre" >"$TMPF" 2>/dev/null ;;
                                                        *)
                                                                groff 
-T$GROFF_DEVICE "$TMPF_pre" >"$TMPF" 2>/dev/null ;;
                                                esac
                                                else echo "groff is not 
available for preprocessing" 1>&2; rm -f "$TMPF"; TMPF="$TMPF_pre"; fi
                                                ;;
                                        *PostScript*)
                                                if [ -x "`which ps2ascii 
2>/dev/null`" ]; then
                                                ps2ascii "$TMPF_pre" >"$TMPF" 
2>/dev/null
                                                else echo "ps2ascii is not 
available for preprocessing" 1>&2; rm -f "$TMPF"; TMPF="$TMPF_pre"; fi
                                                ;;
                                        *HTML*)
                                                if [ -x "`which w3m 
2>/dev/null`" ]; then
                                                w3m -dump -T text/html 
"$TMPF_pre" >"$TMPF" 2>/dev/null
                                                elif [ -x "`which lynx 
2>/dev/null`" ]; then
                                                lynx -dump -force_html 
"$TMPF_pre" >"$TMPF" 2>/dev/null
                                                else echo "lynx/w3m not 
available for preprocessing" 1>&2; rm -f "$TMPF"; TMPF="$TMPF_pre"; fi
                                                ;;
                                        *)
                                                rm -f "$TMPF"
                                                TMPF="$TMPF_pre" 
                                                ;;
                                esac    
                        else
                                rm -f "$TMPF"
                                TMPF="$TMPF_pre"
                        fi
                        ;;
        esac

test "$TMPF_pre" = "$SRC" -o "$TMPF_pre" = "$TMPF" || rm "$TMPF_pre"

test "$TMPF" = "$SRC" || echo "$TMPF"

Reply via email to