Assaf Gordon wrote:
On OpenSoalris 5.11, both i86pc and sun4u, test 'zgrep-signal' fails. log attached. (note: no failure on OpenSolaris 5.10).
I looked into this. First I ran into a different problem; several tests failed because my default installation directory (/usr/local/bin) had some nonworking gzip in it, which 'make check' used during its tests. I installed the first attached patch to fix this.
The problem you reported is because Solaris 5.11 uses ksh for /usr/bin/sh, and this ksh has a funky treatment for exit status of programs that die due to signals like SIGPIPE: the exit status is 256 + signal number. Unfortunately 'exit 257' is equivalent to 'exit 1', i.e., when the shell exits it turns the SIGPIPE into some random nonzero status. I installed the second attached patch, which fixed the problem for me.
>From 7b9903e502657d6f6bf0ae8465a6397a5d0ed9a7 Mon Sep 17 00:00:00 2001 From: Paul Eggert <egg...@cs.ucla.edu> Date: Sat, 5 Mar 2016 17:18:59 -0800 Subject: [PATCH 1/2] gzip: remove --__bindir * NEWS: Document this. * gzexe.in, gunzip.in, zcat.in, zcmp.in, zdiff.in, zegrep.in: * zfgrep.in, zforce.in, zgrep.in, zless.in, zmore.in, znew.in: Remove support for undocumented --__bindir option. Callers can set PATH instead; that's less error-prone. This fixes some 'make check' failures on my Solaris 11 box, which occurred because the test scripts were mistakenly testing the installed gzip rather than the gzip in the working directory. * Makefile.am (.in): Don't replace bindir. (check-local): Set PATH instead of using --__bindir. * tests/help-version (gunzip_setuphelp, gzexe_setuphelp) (zcat_setuphelp, zcmp_setuphelp, zdiff_setuphelp) (zegrep_setuphelp, zfgrep_setuphelp, zforce_setuphelp) (zgrep_setuphelp, zless_setuphelp, zmore_setuphelp) (znew_setuphelp): Remove. All uses removed. (lbracket_setup): Default args to empty. --- Makefile.am | 22 +++++++++++----------- NEWS | 6 ++++++ gunzip.in | 6 ------ gzexe.in | 7 ------- tests/help-version | 32 +++++++------------------------- zcat.in | 6 ------ zcmp.in | 8 +------- zdiff.in | 6 ------ zegrep.in | 7 +------ zfgrep.in | 7 +------ zforce.in | 6 ------ zgrep.in | 6 ------ zless.in | 6 ------ zmore.in | 6 ------ znew.in | 6 ------ 15 files changed, 27 insertions(+), 110 deletions(-) diff --git a/Makefile.am b/Makefile.am index b01ddee..8fb17b9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -82,7 +82,6 @@ SUFFIXES = .in .in: $(AM_V_GEN)sed \ -e 's|/bin/sh|$(SHELL)|g' \ - -e 's|[@]bindir@|'\''$(bindir)'\''|g' \ -e 's|[@]GREP@|$(GREP)|g' \ -e 's|[@]VERSION@|$(VERSION)|g' \ $(srcdir)/$@.in >$@-t \ @@ -108,17 +107,18 @@ gen-ChangeLog: FILES_TO_CHECK = $(bin_SCRIPTS) \ $(top_srcdir)/ChangeLog $(top_srcdir)/configure $(top_srcdir)/gzip.c check-local: $(FILES_TO_CHECK) $(bin_PROGRAMS) gzip.doc.gz - $(AM_V_GEN){ test '$(srcdir)' != . \ - || ./zdiff --__bindir . -c gzip.doc.gz; } - $(AM_V_at)./zdiff --__bindir . -c $(srcdir)/gzip.doc $(srcdir)/gzip.doc - $(AM_V_at)./zdiff --__bindir . $(srcdir)/gzip.doc gzip.doc.gz - $(AM_V_at)./zdiff --__bindir . -c - $(srcdir)/gzip.doc <gzip.doc.gz - $(AM_V_at)./zdiff --__bindir . -c gzip.doc.gz gzip.doc.gz - $(AM_V_at)./zgrep --__bindir . -iV >/dev/null - $(AM_V_at)for opt in --rsyncable '' -1 -9; do \ + $(AM_V_GEN)PATH=.:$$PATH; { test '$(srcdir)' != . \ + || zdiff -c gzip.doc.gz; } + $(AM_V_at)PATH=.:$$PATH; zdiff -c $(srcdir)/gzip.doc $(srcdir)/gzip.doc + $(AM_V_at)PATH=.:$$PATH; zdiff $(srcdir)/gzip.doc gzip.doc.gz + $(AM_V_at)PATH=.:$$PATH; zdiff -c - $(srcdir)/gzip.doc <gzip.doc.gz + $(AM_V_at)PATH=.:$$PATH; zdiff -c gzip.doc.gz gzip.doc.gz + $(AM_V_at)PATH=.:$$PATH; zgrep -iV >/dev/null + $(AM_V_at)PATH=.:$$PATH; \ + for opt in --rsyncable '' -1 -9; do \ for file in $(FILES_TO_CHECK); do \ - ./gzip $$opt -c -- "$$file" \ - | ./gzip -d | cmp - "$$file" || exit 1; \ + gzip $$opt -c -- "$$file" \ + | gzip -d | cmp - "$$file" || exit 1; \ done; \ done diff --git a/NEWS b/NEWS index e3815d1..6363d71 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,12 @@ GNU gzip NEWS -*- outline -*- it is used, and rejects attempts to use dangerous options or operands. You can use an alias or script instead. + Installed programs like 'zgrep' now use the PATH environment variable + as usual to find subsidiary programs like 'gzip' and 'grep'. + Previously they prepended the installation directory to the PATH, + which sometimes caused 'make check' to test the wrong gzip executable. + [bug introduced in gzip-1.3.13] + ** New features gzip now accepts the --synchronous option, which causes it to use diff --git a/gunzip.in b/gunzip.in index d7edb53..1346b35 100644 --- a/gunzip.in +++ b/gunzip.in @@ -17,12 +17,6 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -bindir=@bindir@ -case $1 in ---__bindir) bindir=${2?}; shift; shift;; -esac -PATH=$bindir:$PATH - version="gunzip (gzip) @VERSION@ Copyright (C) 2007, 2011-2016 Free Software Foundation, Inc. This is free software. You may redistribute copies of it under the terms of diff --git a/gzexe.in b/gzexe.in index 6b61ec4..b333993 100644 --- a/gzexe.in +++ b/gzexe.in @@ -53,13 +53,6 @@ Rename each FILE with a compressed version of itself, renaming FILE to FILE~. Report bugs to <bug-gzip@gnu.org>." - -bindir=@bindir@ -case $1 in ---__bindir) bindir=${2?}; shift; shift;; -esac -PATH=$bindir:$PATH - decomp=0 res=0 while :; do diff --git a/tests/help-version b/tests/help-version index 00b4c34..5af9a05 100755 --- a/tests/help-version +++ b/tests/help-version @@ -55,19 +55,6 @@ expected_failure_status_grep=2 expected_failure_status_egrep=2 expected_failure_status_fgrep=2 -gunzip_setuphelp () { args="--__bindir '$abs_top_builddir'"; } -gzexe_setuphelp () { gunzip_setuphelp; } -zcat_setuphelp () { gunzip_setuphelp; } -zcmp_setuphelp () { gunzip_setuphelp; } -zdiff_setuphelp () { gunzip_setuphelp; } -zegrep_setuphelp () { gunzip_setuphelp; } -zfgrep_setuphelp () { gunzip_setuphelp; } -zforce_setuphelp () { gunzip_setuphelp; } -zgrep_setuphelp () { gunzip_setuphelp; } -zless_setuphelp () { gunzip_setuphelp; } -zmore_setuphelp () { gunzip_setuphelp; } -znew_setuphelp () { gunzip_setuphelp; } - test "$built_programs" \ || fail_ "built_programs not specified!?!" @@ -97,11 +84,7 @@ for lang in C fr da; do continue fi - if type ${i}_setuphelp > /dev/null 2>&1; then - ${i}_setuphelp - else - args= - fi + args= # The just-built install executable is always named `ginstall'. test $i = install && i=ginstall @@ -170,18 +153,18 @@ cmp_setup () { args="$tmp_in $tmp_in2"; } # The transfer rate would vary between runs. dd_setup () { args=status=noxfer; } -zdiff_setup () { gunzip_setuphelp; args="$args $zin $zin2"; } +zdiff_setup () { args="$args $zin $zin2"; } zcmp_setup () { zdiff_setup; } -zcat_setup () { gunzip_setuphelp; args="$args $zin"; } +zcat_setup () { args="$args $zin"; } gunzip_setup () { zcat_setup; } zmore_setup () { zcat_setup; } zless_setup () { zcat_setup; } -znew_setup () { gunzip_setuphelp; args="$args $bigZ_in"; } +znew_setup () { args="$args $bigZ_in"; } zforce_setup () { zcat_setup; } -zgrep_setup () { gunzip_setuphelp; args="$args z $zin"; } +zgrep_setup () { args="$args z $zin"; } zegrep_setup () { zgrep_setup; } zfgrep_setup () { zgrep_setup; } -gzexe_setup () { gunzip_setuphelp; args="$args $tmp_in"; } +gzexe_setup () { args="$args $tmp_in"; } # We know that $tmp_in contains a "0" grep_setup () { args="0 $tmp_in"; } @@ -271,10 +254,9 @@ for i in $built_programs; do mkdir $tmp_dir # echo ================== $i test $i = [ && prog=lbracket || prog=$i + args= if type ${prog}_setup > /dev/null 2>&1; then ${prog}_setup - else - args= fi if eval "env \$i $args < \$tmp_in > \$tmp_out"; then : # ok diff --git a/zcat.in b/zcat.in index d8ffd85..54befb4 100644 --- a/zcat.in +++ b/zcat.in @@ -17,12 +17,6 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -bindir=@bindir@ -case $1 in ---__bindir) bindir=${2?}; shift; shift;; -esac -PATH=$bindir:$PATH - version="zcat (gzip) @VERSION@ Copyright (C) 2007, 2011-2016 Free Software Foundation, Inc. This is free software. You may redistribute copies of it under the terms of diff --git a/zcmp.in b/zcmp.in index d099223..eeee247 100644 --- a/zcmp.in +++ b/zcmp.in @@ -17,12 +17,6 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -bindir=@bindir@ -case $1 in ---__bindir) bindir=${2?}; shift; shift;; -esac -PATH=$bindir:$PATH - version="zcmp (gzip) @VERSION@ Copyright (C) 2010 Free Software Foundation, Inc. This is free software. You may redistribute copies of it under the terms of @@ -48,4 +42,4 @@ case $1 in --version) echo "$version" || st=2; exit $st;; esac -exec zdiff --__bindir "$bindir" --__cmp "$@" +exec zdiff --__cmp "$@" diff --git a/zdiff.in b/zdiff.in index f1fa95f..f2f5435 100644 --- a/zdiff.in +++ b/zdiff.in @@ -18,12 +18,6 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -bindir=@bindir@ -case $1 in ---__bindir) bindir=${2?}; shift; shift;; -esac -PATH=$bindir:$PATH - case $1 in --__cmp) shift prog=cmp; cmp='${CMP-cmp}' ;; diff --git a/zegrep.in b/zegrep.in index 99855ef..e5969b7 100644 --- a/zegrep.in +++ b/zegrep.in @@ -1,7 +1,2 @@ #!/bin/sh -bindir=@bindir@ -case $1 in ---__bindir) bindir=${2?}; shift; shift;; -esac -PATH=$bindir:$PATH -exec zgrep --__bindir "$bindir" -E "$@" +exec zgrep -E "$@" diff --git a/zfgrep.in b/zfgrep.in index df17201..fd7be2b 100644 --- a/zfgrep.in +++ b/zfgrep.in @@ -1,7 +1,2 @@ #!/bin/sh -bindir=@bindir@ -case $1 in ---__bindir) bindir=${2?}; shift; shift;; -esac -PATH=$bindir:$PATH -exec zgrep --__bindir "$bindir" -F "$@" +exec zgrep -F "$@" diff --git a/zforce.in b/zforce.in index 5baff07..82ad330 100644 --- a/zforce.in +++ b/zforce.in @@ -23,12 +23,6 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -bindir=@bindir@ -case $1 in ---__bindir) bindir=${2?}; shift; shift;; -esac -PATH=$bindir:$PATH; export PATH - version="zforce (gzip) @VERSION@ Copyright (C) 2010-2016 Free Software Foundation, Inc. This is free software. You may redistribute copies of it under the terms of diff --git a/zgrep.in b/zgrep.in index d94b8d8..0ad1b8a 100644 --- a/zgrep.in +++ b/zgrep.in @@ -22,12 +22,6 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -bindir=@bindir@ -case $1 in ---__bindir) bindir=${2?}; shift; shift;; -esac -PATH=$bindir:$PATH - grep='${GREP-'\''@GREP@'\''}' version='zgrep (gzip) @VERSION@ diff --git a/zless.in b/zless.in index a3edcc7..e634af6 100644 --- a/zless.in +++ b/zless.in @@ -16,12 +16,6 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -bindir=@bindir@ -case $1 in ---__bindir) bindir=${2?}; shift; shift;; -esac -PATH=$bindir:$PATH; export PATH - version="zless (gzip) @VERSION@ Copyright (C) 2007, 2011-2016 Free Software Foundation, Inc. This is free software. You may redistribute copies of it under the terms of diff --git a/zmore.in b/zmore.in index b1bb68f..0193a1b 100644 --- a/zmore.in +++ b/zmore.in @@ -17,12 +17,6 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -bindir=@bindir@ -case $1 in ---__bindir) bindir=${2?}; shift; shift;; -esac -PATH=$bindir:$PATH; export PATH - version="zmore (gzip) @VERSION@ Copyright (C) 2010-2016 Free Software Foundation, Inc. This is free software. You may redistribute copies of it under the terms of diff --git a/znew.in b/znew.in index ec025d2..12f89fc 100644 --- a/znew.in +++ b/znew.in @@ -18,12 +18,6 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -bindir=@bindir@ -case $1 in ---__bindir) bindir=${2?}; shift; shift;; -esac -PATH=$bindir:$PATH; export PATH - version="znew (gzip) @VERSION@ Copyright (C) 2010-2016 Free Software Foundation, Inc. This is free software. You may redistribute copies of it under the terms of -- 2.5.0
>From b8b9b66e73ce2ccf3e40e7f4450880b8881734a5 Mon Sep 17 00:00:00 2001 From: Paul Eggert <egg...@cs.ucla.edu> Date: Sun, 6 Mar 2016 00:17:41 -0800 Subject: [PATCH 2/2] gzip: port zgrep to Solaris 11.2 Problem reported by Assaf Gordon in: http://bugs.gnu.org/22900#11 * zgrep.in: Port to Solaris 11.2 /bin/sh (ksh 93u 2011-02-08), where $? is 256+SIG when a process was killed with signal SIG, and where 'exit 257' is equivalent to 'exit 1'. Apparently some other sh implementations use 256+128+SIG. So, instead of using plain 'exit $?', use the equivalent of 'exit ((128 * (128 <= $?)) + $? % 128)' within the script, and use the equivalent of 'kill -$($? % 128)' at the top level if the exit status is 128 or more. --- zgrep.in | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/zgrep.in b/zgrep.in index 0ad1b8a..bbea331 100644 --- a/zgrep.in +++ b/zgrep.in @@ -183,6 +183,7 @@ do if test $r -eq 1; then printf '%s\n' "$i" || r=2 fi + test 256 -le $r && r=$(expr 128 + $r % 128) exit $r } elif test $with_filename -eq 0 && @@ -202,12 +203,13 @@ do sed_script="s|^|$i:|" # Fail if grep or sed fails. - r=$( - exec 4>&1 - (eval "$grep" 4>&-; echo $? >&4) 3>&- | sed "$sed_script" >&3 4>&- - ) && exit $r - r=$? - test 1 -lt $r && exit $r || exit 2 + if r=$( + exec 4>&1 + (eval "$grep" 4>&-; echo $? >&4) 3>&- | sed "$sed_script" >&3 4>&- + ) || { r=$?; test $r -lt 2 && r=2; :; }; then + test 256 -le $r && r=$(expr 128 + $r % 128) + exit $r + fi fi >&3 5>&- ) r=$? @@ -220,14 +222,16 @@ do # Use the more serious of the grep and gzip statuses. test $r -lt $gzip_status && r=$gzip_status - # Exit immediately on software configuration error. - test 126 -le $r && exit $r - # Accumulate the greatest status, except consider 0 to be greater than 1. if test $r -le 1 && test $res -le 1; then test $r -lt $res else test $res -lt $r fi && res=$r + + # Exit immediately on a serious error. + test 126 -le $res && break done + +test 128 -le $res && kill -$(expr $res % 128) $$ exit $res -- 2.5.0