From 55890dd7327178b8b04cd6aa895f1a9b4fb6ea99 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 3 Feb 2023 01:20:18 -0800 Subject: [PATCH] zless: improve gzip failure checking * zless.in: Use --show-preproc-error if available. --- NEWS | 2 ++ zless.in | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) 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 "$@"