diff --git a/.gitignore b/.gitignore index f6cddbb..ab1d9fe 100644 --- a/.gitignore +++ b/.gitignore @@ -5,12 +5,3 @@ /less-575.tar.gz /less-581.2.tar.gz /less-590.tar.gz -/less-608.tar.gz -/less-633.tar.gz -/less-643.tar.gz -/less-661.tar.gz -/less-668.tar.gz -/less-678.tar.gz -/less-679.tar.gz -/less-685.tar.gz -/lesspipe-2.20.tar.gz diff --git a/less-436-help.patch b/less-436-help.patch index d58498b..09821c3 100644 --- a/less-436-help.patch +++ b/less-436-help.patch @@ -1,7 +1,8 @@ -diff -up less-661/help.c.help less-661/help.c ---- less-661/help.c.help 2024-08-05 21:40:34.531327397 +0200 -+++ less-661/help.c 2024-08-05 21:40:34.533327418 +0200 -@@ -137,7 +137,7 @@ constant char helpdata[] = { +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', @@ -10,10 +11,23 @@ diff -up less-661/help.c.help less-661/help.c ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','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', -diff -up less-661/less.hlp.help less-661/less.hlp ---- less-661/less.hlp.help 2024-08-05 21:40:34.532327408 +0200 -+++ less-661/less.hlp 2024-08-05 21:40:34.533327418 +0200 -@@ -134,7 +134,7 @@ +@@ -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. @@ -22,3 +36,15 @@ diff -up less-661/less.hlp.help less-661/less.hlp 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-458-less-filters-man.patch b/less-458-less-filters-man.patch index 90e7207..7de4415 100644 --- a/less-458-less-filters-man.patch +++ b/less-458-less-filters-man.patch @@ -20,5 +20,5 @@ diff -up less-466/less.nro.filters-man less-466/less.nro +~/.lessfilter tries to handle the file. + .SH "NATIONAL CHARACTER SETS" - There are five types of characters in the input file: + There are three types of characters in the input file: .IP "normal characters" diff --git a/less-458-lessecho-usage.patch b/less-458-lessecho-usage.patch index b16369b..14a7f37 100644 --- a/less-458-lessecho-usage.patch +++ b/less-458-lessecho-usage.patch @@ -2,7 +2,7 @@ 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; - static void pr_usage(void) + pr_usage(VOID_PARAM) { fprintf(stderr, - "usage: lessecho [-ox] [-cx] [-pn] [-dn] [-mx] [-nn] [-ex] [-fn] [-a] file ...\n"); @@ -29,5 +29,5 @@ diff -upr less-458_orig/lessecho.c less-458_work/lessecho.c + " -?\t- prints this help\n"); } - static void pr_version(void) + static void diff --git a/less-458-lesskey-usage.patch b/less-458-lesskey-usage.patch index e9c5cc3..1ebf55f 100644 --- a/less-458-lesskey-usage.patch +++ b/less-458-lesskey-usage.patch @@ -2,8 +2,8 @@ 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[]; - - static void usage(void) + static void + usage(void) { - fprintf(stderr, "usage: lesskey [-o output] [input]\n"); + fprintf(stderr, "usage: lesskey [-o output] [input]\n\n"); diff --git a/less-475-fsync.patch b/less-475-fsync.patch index 7f7a189..ce81b48 100644 --- a/less-475-fsync.patch +++ b/less-475-fsync.patch @@ -1,7 +1,15 @@ -diff -up less-678-build/less-678/configure.ac.fsync less-678-build/less-678/configure.ac ---- less-678-build/less-678/configure.ac.fsync 2025-05-01 22:42:03.000000000 +0200 -+++ less-678-build/less-678/configure.ac 2025-05-22 18:10:23.572796329 +0200 -@@ -210,6 +210,8 @@ AH_TEMPLATE([HAVE_TIME_T], +From 5396b6b77d0248678f716038dc747d6898acb0b3 Mon Sep 17 00:00:00 2001 +From: Stephen Gallagher +Date: Fri, 22 Jan 2021 09:49:13 -0500 +Subject: [PATCH] Test for fsync on tty + +Signed-off-by: Stephen Gallagher + +Modified for less 581.2 Filip Januš +diff -ur less-581.2/configure.ac less_fsync/configure.ac +--- less-581.2/configure.ac 2021-04-28 17:00:08.000000000 +0200 ++++ less_fsync/configure.ac 2021-05-06 10:59:07.560062397 +0200 +@@ -221,6 +221,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.]) @@ -10,18 +18,18 @@ diff -up less-678-build/less-678/configure.ac.fsync less-678-build/less-678/conf AH_TEMPLATE([HAVE_FILENO], [Define HAVE_FILENO if you have the fileno() macro.]) AH_TEMPLATE([HAVE_ERRNO], -@@ -259,7 +261,7 @@ AC_MSG_CHECKING(for ANSI function protot - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int f(int a) { return a; }]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ANSI_PROTOS)],[AC_MSG_RESULT(no)]) +@@ -274,7 +276,7 @@ # Checks for library functions. --AC_CHECK_FUNCS([fchmod fsync nanosleep poll popen realpath _setjmp sigprocmask sigsetmask snprintf stat strsignal system ttyname usleep]) -+AC_CHECK_FUNCS([fchmod nanosleep poll popen realpath _setjmp sigprocmask sigsetmask snprintf stat strsignal system ttyname usleep]) - AC_CHECK_DECL(sigsetjmp, [AC_DEFINE(HAVE_SIGSETJMP)], [], [#include ]) + AC_TYPE_SIGNAL +-AC_CHECK_FUNCS([fchmod fsync nanosleep poll popen realpath _setjmp sigprocmask sigsetmask snprintf stat system ttyname usleep]) ++AC_CHECK_FUNCS([fchmod nanosleep poll popen realpath _setjmp sigprocmask sigsetmask snprintf stat system ttyname usleep]) # AC_CHECK_FUNCS may not work for inline functions, so test these separately. -@@ -302,6 +304,16 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include - #endif]], [[static char *x; x = strerror(0);]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRERROR)],[AC_MSG_RESULT(no)]) + AC_MSG_CHECKING(for memcpy) +@@ -321,6 +323,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([ @@ -34,5 +42,5 @@ diff -up less-678-build/less-678/configure.ac.fsync less-678-build/less-678/conf +}], [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FSYNC)], [AC_MSG_RESULT(no)]) + AC_MSG_CHECKING(for sys_errlist) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[extern char *sys_errlist[]; static char **x; x = sys_errlist;]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYS_ERRLIST)],[AC_MSG_RESULT(no)]) - + 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-590-hyperlink-bleed.patch b/less-590-hyperlink-bleed.patch new file mode 100644 index 0000000..96a6b34 --- /dev/null +++ b/less-590-hyperlink-bleed.patch @@ -0,0 +1,77 @@ +From a99bf3bf475057a2562bf89860c60b0c2a000d4a Mon Sep 17 00:00:00 2001 +From: "FeRD (Frank Dana)" +Date: Fri, 22 Oct 2021 14:22:23 -0400 +Subject: [PATCH] Backport of 089d6651 to less 590 + +--- + line.c | 24 ++++++++++++++++++++---- + 1 file changed, 20 insertions(+), 4 deletions(-) + +diff --git a/line.c b/line.c +index b8f609e..a587f71 100644 +--- a/line.c ++++ b/line.c +@@ -38,6 +38,7 @@ struct xbuffer last_ansi; + + public int size_linebuf = 0; /* Size of line buffer (and attr buffer) */ + static struct ansi_state *line_ansi = NULL; ++static int hlink_in_line; + static int cshift; /* Current left-shift of output line buffer */ + public int hshift; /* Desired left-shift of output line buffer */ + public int tabstops[TABSTOP_MAX] = { 0 }; /* Custom tabstops */ +@@ -221,6 +222,7 @@ prewind(VOID_PARAM) + is_null_line = 0; + pendc = '\0'; + in_hilite = 0; ++ hlink_in_line = 0; + xbuf_reset(&shifted_ansi); + xbuf_reset(&last_ansi); + } +@@ -251,6 +253,19 @@ add_linebuf(ch, attr, w) + inc_end_column(w); + } + ++/* ++ * Append a string to the line buffer. ++ */ ++ static void ++addstr_linebuf(s, attr, cw) ++ char *s; ++ int attr; ++ int cw; ++{ ++ for ( ; *s != '\0'; s++) ++ add_linebuf(*s, attr, cw); ++} ++ + /* + * Set a character in the line prefix buffer. + */ +@@ -958,6 +973,8 @@ store_ansi(ch, rep, pos) + case ANSI_MID: + if (!in_hilite) + STORE_CHAR(ch, AT_ANSI, rep, pos); ++ if (line_ansi->hlink) ++ hlink_in_line = 1; + break; + case ANSI_END: + if (!in_hilite) +@@ -1138,12 +1155,11 @@ pflushmbc(VOID_PARAM) + static void + add_attr_normal(VOID_PARAM) + { +- char *p = "\033[m"; +- + if (ctldisp != OPT_ONPLUS || !is_ansi_end('m')) + return; +- for ( ; *p != '\0'; p++) +- add_linebuf(*p, AT_ANSI, 0); ++ addstr_linebuf("\033[m", AT_ANSI, 0); ++ if (hlink_in_line) /* Don't send hyperlink clear if we know we don't need to. */ ++ addstr_linebuf("\033]8;;\033\\", AT_ANSI, 0); + } + + /* +-- +2.31.1 + diff --git a/less.spec b/less.spec index 51d2494..fa54369 100644 --- a/less.spec +++ b/less.spec @@ -1,32 +1,27 @@ Summary: A text file browser similar to more, but better Name: less -Version: 685 -Release: 6%{?dist} -License: GPL-3.0-only and BSD-2-Clause +Version: 590 +Release: 2%{?dist} +License: GPLv3+ or BSD Source0: https://www.greenwoodsoftware.com/less/%{name}-%{version}.tar.gz -%global lesspipe_version 2.20 -Source1: https://github.com/wofr06/lesspipe/archive/refs/tags/v%{lesspipe_version}.tar.gz#/lesspipe-%{lesspipe_version}.tar.gz +Source1: lesspipe.sh Source2: less.sh Source3: less.csh Patch4: less-394-time.patch Patch5: less-475-fsync.patch Patch6: less-436-manpage-add-old-bot-option.patch +Patch7: less-436-help.patch Patch8: less-458-lessecho-usage.patch Patch9: less-458-less-filters-man.patch Patch10: less-458-lesskey-usage.patch Patch11: less-458-old-bot-in-help.patch -Patch13: less-436-help.patch +# Backported version of upstream commit d21820c +# https://github.com/gwsw/less/commit/d21820c9d8501b5814d33d4fb8a621c6c563e102 +Patch12: less-590-hyperlink-bleed.patch URL: https://www.greenwoodsoftware.com/less/ BuildRequires: ncurses-devel BuildRequires: autoconf automake libtool BuildRequires: make -# for lesspipe make test -BuildRequires: perl-Archive-Tar -# for lesspipe -Recommends: (less-color = %{version}-%{release} if perl-interpreter) -Recommends: unzip -Recommends: html2text -Recommends: 7zip %description The less utility is a text file browser that resembles more, but has @@ -38,25 +33,17 @@ example, vi). You should install less because it is a basic utility for viewing text files, and you'll use it frequently. -%package color -Summary: Colorizers for less -Requires: %{name} = %{version}-%{release} -Conflicts: less < 685-5 - -%description color -Syntax highlighting modes for the less pager. - - %prep -%setup -q -a 1 -%patch -P 4 -p1 -b .time -%patch -P 5 -p2 -b .fsync -%patch -P 6 -p1 -b .manpage-add-old-bot-option -%patch -P 8 -p1 -b .lessecho-usage -%patch -P 9 -p1 -b .less-filters-man -%patch -P 10 -p1 -b .lesskey-usage -%patch -P 11 -p1 -b .old-bot -%patch -P 13 -p1 -b .help +%setup -q +%patch4 -p1 -b .time +%patch5 -p1 -b .fsync +%patch6 -p1 -b .manpage-add-old-bot-option +%patch7 -p1 -b .help +%patch8 -p1 -b .lessecho-usage +%patch9 -p1 -b .less-filters-man +%patch10 -p1 -b .lesskey-usage +%patch11 -p1 -b .old-bot +%patch12 -p1 -b .hyperlinks %build @@ -65,125 +52,21 @@ autoreconf -fiv %configure %make_build CFLAGS="%{optflags} -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" -pushd lesspipe-%{lesspipe_version} -#fix shebangs -sed -i "s|^#!/usr/bin/env bash|^#!/usr/bin/bash|" lesspipe.sh - -./configure --prefix=%{_prefix} -%make_build -popd - %install %make_install mkdir -p $RPM_BUILD_ROOT/etc/profile.d +install -p %{SOURCE1} $RPM_BUILD_ROOT%{_bindir} install -p -m 644 %{SOURCE2} $RPM_BUILD_ROOT/etc/profile.d install -p -m 644 %{SOURCE3} $RPM_BUILD_ROOT/etc/profile.d -pushd lesspipe-%{lesspipe_version} -%make_install -rm -f $RPM_BUILD_ROOT/usr/share/bash-completion/less_completion -popd - -%check -pushd lesspipe-%{lesspipe_version} -# we dont have all required components to pass full test, but it is still -# useful to run for debug purposes -make test ||: -popd - %files %doc README NEWS INSTALL %license LICENSE COPYING /etc/profile.d/* -%{_bindir}/less -%{_bindir}/lesscomplete -%{_bindir}/lessecho -%{_bindir}/lesskey -%{_bindir}/lesspipe.sh +%{_bindir}/* %{_mandir}/man1/* -%files color -%{_bindir}/archive_color -%{_bindir}/code2color -%{_bindir}/sxw2txt -%{_bindir}/vimcolor - %changelog -* Mon Nov 24 2025 Michal Hlavinka - 685-6 -- reintroduce use more feature rich lesspipe filter, but separate - perl dependent colorizer into subpackage, credits Yaakov Selkowitz - -* Fri Nov 14 2025 Adam Williamson - 685-5 -- Revert new lesspipe filter due to hard perl dependency - -* Wed Nov 12 2025 Michal Hlavinka - 685-4 -- use more feature rich lesspipe filter (#2308285) - -* Wed Oct 22 2025 Michal Hlavinka - 685-1 -- updated to 685 (#2404089) - -* Tue Sep 02 2025 Michal Hlavinka - 679-4 -- add man page for lesspipe.sh (rhbz#2376159) - -* Thu Jul 24 2025 Fedora Release Engineering - 679-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild - -* Mon Jun 23 2025 Michal Hlavinka - 679-1 -- updated to 679 - -* Thu May 22 2025 Michal Hlavinka - 678-1 -- updated to 678 (#2367012) - -* Fri Jan 17 2025 Fedora Release Engineering - 668-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild - -* Fri Oct 18 2024 Michal Hlavinka - 668-1 -- updated to 668 (#2319532) - -* Mon Aug 12 2024 Michal Hlavinka - 661-2 -- fix post-v590 regression causing reading only part of pipe when stdin is null (upstream#558) - -* Fri Jul 26 2024 Michal Hlavinka - 661-1 -- updated to 661(2294840) - -* Thu Jul 18 2024 Fedora Release Engineering - 643-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild - -* Tue Feb 06 2024 Matej Mužila - 643-4 -- migrated to SPDX license - -* Thu Jan 25 2024 Fedora Release Engineering - 643-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild - -* Sun Jan 21 2024 Fedora Release Engineering - 643-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild - -* Tue Sep 05 2023 Matej Mužila - 643-1 -- Update to new upstream release -- Resolves: #2231663 - -* Thu Jul 20 2023 Fedora Release Engineering - 633-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild - -* Fri May 05 2023 Matej Mužila - 633-1 -- Update to new upstream release -- Resolves: CVE-2022-46663 - -* Thu Jan 19 2023 Fedora Release Engineering - 608-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild - -* Thu Nov 24 2022 Matej Mužila - 608-1 -- Update to new upstream release - -* Mon Jul 25 2022 Daan De Meyer - 590-5 -- Backport patch from upstream to fix memory leak - -* Thu Jul 21 2022 Fedora Release Engineering - 590-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild - -* Thu Jan 20 2022 Fedora Release Engineering - 590-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild - * Sat Oct 02 2021 FeRD (Frank Dana) - 590-2 - Backport patch from upstream to fix hyperlinked text bug diff --git a/lesspipe.sh b/lesspipe.sh new file mode 100755 index 0000000..f2df6a1 --- /dev/null +++ b/lesspipe.sh @@ -0,0 +1,128 @@ +#!/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|*.[1-9n].zst|*.[1-9]x.zst|*.man.zst|*.[1-9n].br|*.[1-9]x.br|*.man.br) + case "$1" in + *.gz) DECOMPRESSOR="gzip -dc" ;; + *.bz2) DECOMPRESSOR="bzip2 -dc" ;; + *.lz) DECOMPRESSOR="lzip -dc" ;; + *.zst) DECOMPRESSOR="zstd -dcq" ;; + *.br) DECOMPRESSOR="brotli -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.zst) tar --zstd -tvvf "$1"; exit $? ;; +*.zst) zstd -dcq -- "$1"; exit $? ;; +*.tar.br) brotli -dc -- "$1" | tar tvvf -; exit $? ;; +*.br) brotli -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 diff --git a/sources b/sources index 703a9df..39e4ba0 100644 --- a/sources +++ b/sources @@ -1,2 +1 @@ -SHA512 (less-685.tar.gz) = aff745f1816e0f996fbdbc33ecae0726cf0d842efc227937ff8c32e734c8b5be4c611ffbb27e5e038b4d95280c95ca60c53af1a47cf419cb06e5fab543c231f3 -SHA512 (lesspipe-2.20.tar.gz) = bfeba1b921959e8cde8ce8bcc75765598cefd2cc705aa5b6417592fdbdb0c43bd3efb0d4379a0514f0da86806988ee95219539974c7af3319595d9b03aac550e +SHA512 (less-590.tar.gz) = 426fa5840fd43c17bd5a452ad35ad24f2d6684623c6914403fd0059af62266bf2138e6828c7d73a1cef26a736c0d2b8ed4ab180eea8297281dae79a4228eb903