zless: improve gzip failure checking

* zless.in: Use --show-preproc-error if available.
This commit is contained in:
Paul Eggert 2023-02-03 01:20:18 -08:00
parent 75dac03adc
commit 55890dd732
2 changed files with 12 additions and 1 deletions

2
NEWS
View File

@ -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

View File

@ -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 "$@"