aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2024-02-09 23:00:05 +0200
committerLasse Collin <lasse.collin@tukaani.org>2024-02-09 23:00:05 +0200
commitfd0692b0525e6c26b496492be9e2c865cab734f8 (patch)
treeabf6ab118ece6dd1d01e355c3169c7a7ee9d3842
parentliblzma: Fix typo discovered by codespell. (diff)
downloadxz-fd0692b0525e6c26b496492be9e2c865cab734f8.tar.xz
xzless: Use --show-preproc-errors with "less" 632 and newer.
This makes "less" show a warning if a decompression error occurred.
-rw-r--r--src/scripts/xzless.in11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/scripts/xzless.in b/src/scripts/xzless.in
index 79a849e2..93a415d7 100644
--- a/src/scripts/xzless.in
+++ b/src/scripts/xzless.in
@@ -47,13 +47,20 @@ 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 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 "$@"