bootstrap: don't use cmp's -s option when reading from a pipe
authorJim Meyering <meyering@redhat.com>
Mon, 29 Dec 2008 19:43:48 +0000 (20:43 +0100)
committerJim Meyering <meyering@redhat.com>
Thu, 1 Jan 2009 01:15:07 +0000 (02:15 +0100)
GNU cmp exits without reading all input when given the -s option,
and that can cause termination of the writing process via SIGPIPE.
Instead, when reading from a pipe, just redirect output to /dev/null
so that all input is read.

bootstrap

index 0b015ef..3264171 100755 (executable)
--- a/bootstrap
+++ b/bootstrap
@@ -198,7 +198,7 @@ insert_sorted_if_absent() {
   file=$1
   str=$2
   test -f $file || touch $file
-  echo "$str" | sort -u - $file | cmp -s - $file \
+  echo "$str" | sort -u - $file | cmp - $file > /dev/null \
     || echo "$str" | sort -u - $file -o $file \
     || exit 1
 }
@@ -585,7 +585,7 @@ slurp() {
       if test $file = Makefile.am; then
         copied=$copied${sep}$gnulib_mk; sep=$nl
        remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
-        sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/$gnulib_mk || {
+        sed "$remove_intl" $1/$dir/$file | cmp - $dir/$gnulib_mk > /dev/null || {
          echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
          rm -f $dir/$gnulib_mk &&
          sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk