summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2023-02-03 01:20:18 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2023-02-03 01:26:07 -0800
commit55890dd7327178b8b04cd6aa895f1a9b4fb6ea99 (patch)
tree25856e1327e10a57941792600cc1e3b871f6f7a3
parent75dac03adcdf79b8d38a87bf29f50bcde9fa46a5 (diff)
downloadgzip-55890dd7327178b8b04cd6aa895f1a9b4fb6ea99.tar.gz
zless: improve gzip failure checking
* zless.in: Use --show-preproc-error if available.
-rw-r--r--NEWS2
-rw-r--r--zless.in11
2 files changed, 12 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index da3829d..5305e61 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ GNU gzip NEWS -*- outline -*-
** Changes in behavior
+ zless now diagnoses gzip failures, if using less 623 or later.
+
When SIGPIPE is ignored, gzip now exits with status 2 (warning)
instead of status 1 (error) when writing to a broken pipe. This is
more useful with programs like 'less' that treat gzip exit status 2
diff --git a/zless.in b/zless.in
index 7d4d3e4..52767a2 100644
--- a/zless.in
+++ b/zless.in
@@ -64,8 +64,17 @@ less' '[1-9][0-9][0-9][0-9]*)
use_input_pipe_on_stdin='-';;
*) use_input_pipe_on_stdin='';;
esac
+case $less_version in
+less' '623* | \
+less' '62[4-9]* | \
+less' '6[3-9][0-9]* | \
+less' '[7-9][0-9][0-9]* | \
+less' '[1-9][0-9][0-9][0-9]*)
+ show_preproc_error='--show-preproc-error';;
+*) show_preproc_error='';;
+esac
LESSOPEN="|$check_exit_status${use_input_pipe_on_stdin}'gzip' -cdfq -- %s"
export LESSOPEN
-exec less "$@"
+exec less $show_preproc_error "$@"