zless: improve gzip failure checking, and port to new -V format
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 7 Mar 2014 01:31:25 +0000 (17:31 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 7 Mar 2014 01:35:12 +0000 (17:35 -0800)
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

index 92209f27e60c7f293a912339057dd8ec800bc5c2..67760b3303caf10b71da2923f71ca3360c02fe46 100644 (file)
--- 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 "$@"