summaryrefslogtreecommitdiffstats
path: root/src/scripts/xzless.in
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-15 09:41:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-15 09:41:34 +0000
commit25e43e389c26d56f90f2f20e3cee19c808b2a18c (patch)
treefdadca249ffd70901103b3f06a98aeab695c6193 /src/scripts/xzless.in
parentAdding debian version 5.6.1+really5.4.5-1. (diff)
downloadxz-utils-25e43e389c26d56f90f2f20e3cee19c808b2a18c.tar.xz
xz-utils-25e43e389c26d56f90f2f20e3cee19c808b2a18c.zip
Merging upstream version 5.6.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/scripts/xzless.in')
-rw-r--r--src/scripts/xzless.in21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/scripts/xzless.in b/src/scripts/xzless.in
index 79a849e..6346966 100644
--- a/src/scripts/xzless.in
+++ b/src/scripts/xzless.in
@@ -1,4 +1,5 @@
#!@POSIX_SHELL@
+# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 1998, 2002, 2006, 2007 Free Software Foundation
@@ -23,7 +24,7 @@
# specified via XZ_OPT.
xz='@xz@ --format=auto'
-version='xzless (@PACKAGE_NAME@) @VERSION@'
+version='xzless (@PACKAGE_NAME@) @PACKAGE_VERSION@'
usage="Usage: ${0##*/} [OPTION]... [FILE]...
Like 'less', but operate on the uncompressed contents of xz compressed FILEs.
@@ -47,13 +48,27 @@ if test "${LESSMETACHARS+set}" != set; then
LESSMETACHARS="$space$tab$nl'"';*?"()<>[|&^`#\$%=~'
fi
-if test "$(less -V | { read _ ver _ && echo ${ver%%.*}; })" -ge 429; then
+VER=$(less -V | { read _ ver _ && echo ${ver%%.*}; })
+if test "$VER" -ge 451; then
+ # less 451 or later: If the compressed file is valid but has
+ # zero bytes of uncompressed data, using two vertical bars ||- makes
+ # "less" check the exit status of xz and if it is zero then display
+ # an empty file. With a single vertical bar |- and no output from xz,
+ # "less" would attempt to display the raw input file instead.
+ LESSOPEN="||-$xz -cdfqQ -- %s"
+elif test "$VER" -ge 429; then
# less 429 or later: LESSOPEN pipe will be used on
# standard input if $LESSOPEN begins with |-.
LESSOPEN="|-$xz -cdfqQ -- %s"
else
LESSOPEN="|$xz -cdfqQ -- %s"
fi
+
+SHOW_PREPROC_ERRORS=
+if test "$VER" -ge 632; then
+ SHOW_PREPROC_ERRORS=--show-preproc-errors
+fi
+
export LESSMETACHARS LESSOPEN
-exec less "$@"
+exec less $SHOW_PREPROC_ERRORS "$@"