From c0beeb5bc3c7120fea67eb9122f467e646abb6ed Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 6 Mar 2014 17:31:25 -0800 Subject: [PATCH] zless: improve gzip failure checking, and port to new -V format Problem reported by Jaroslaw Weglinski, and LESSOPEN change suggested by Mark Nudelman, in: http://bugs.gnu.org/16951 This doesn't fix bug 16951 entirely, as 'less' needs to be changed too, but it's a start. * zless.in (check_exit_status): New var. (LESSOPEN): Use it. (use_input_pipe_on_stdin): Adjust to output format on Fedora 20, where 'less -V' outputs "less 458 (POSIX regular expressions)" on the first line. --- zless.in | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/zless.in b/zless.in index 92209f2..67760b3 100644 --- a/zless.in +++ b/zless.in @@ -55,13 +55,23 @@ fi less_version=`less -V` || exit case $less_version in -'less 429 -'* | 'less '4[3-9][0-9]* | 'less '[5-9][0-9][0-9]* | 'less '[1-9][0-9][0-9][0-9]*) +less' '45[1-9]* | \ +less' '4[6-9][0-9]* | \ +less' '[5-9][0-9][0-9]* | \ +less' '[1-9][0-9][0-9][0-9]*) + check_exit_status='|';; +*) check_exit_status='';; +esac +case $less_version in +less' '429* | \ +less' '4[3-9][0-9]* | \ +less' '[5-9][0-9][0-9]* | \ +less' '[1-9][0-9][0-9][0-9]*) use_input_pipe_on_stdin='-';; *) use_input_pipe_on_stdin='';; esac -LESSOPEN="|${use_input_pipe_on_stdin}gzip -cdfq -- %s" +LESSOPEN="|$check_exit_status${use_input_pipe_on_stdin}gzip -cdfq -- %s" export LESSOPEN exec less "$@" -- 1.8.5.3