]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
xzless: Use --show-preproc-errors with "less" 632 and newer.
authorLasse Collin <lasse.collin@tukaani.org>
Fri, 9 Feb 2024 21:00:05 +0000 (23:00 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Fri, 9 Feb 2024 21:00:05 +0000 (23:00 +0200)
This makes "less" show a warning if a decompression error occurred.

src/scripts/xzless.in

index 79a849e2e2fdcd06b3deea1919ed90da0cc833b1..93a415d7a92650d8bcec42b00b8608e886d4726b 100644 (file)
@@ -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 "$@"