Subject: bug#21696: FYI: two maint patches [was Re: bug#21696: ...

From: Jim Meyering <[email-masked]>
Date: Sat, 17 Oct 2015 21:10:09 -0700

On Sat, Oct 17, 2015 at 4:12 PM, Norihiro Tanaka <[email-masked]> wrote:
> On Sat, 17 Oct 2015 08:11:21 -0700
> Jim Meyering <[email-masked]> wrote:
>
>> I would like to make a prerelease snapshot late today or tomorrow, so
>> if you know of any quick/trivial improvements or anything
>> bug-fix-related, please let me know soon.

FYI, I've just pushed these:
From d34269c09dffc4dae884fc1fc63384c6ef706a1d Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email-masked]>
Date: Sat, 17 Oct 2015 16:26:58 -0700
Subject: [PATCH 1/2] build: avoid spurious bootstrap failure involving pkg.m4

Running ./bootstrap could fail mistakenly at the very end in
its attempt to obtain a copy of pkg.m4.  It would search only
$(aclocal --print-ac-dir) and some other directories, but not
those listed in $(aclocal --print-ac-dir)/dirlist.
* bootstrap.conf (bootstrap_post_import_hook): Also search the
directories named in $(aclocal --print-ac-dir)/dirlist when that
file exists with nonzero size.
---
 bootstrap.conf | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bootstrap.conf b/bootstrap.conf
index 7842928..9db620b 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -136,10 +136,12 @@ bootstrap_post_import_hook ()
   touch ChangeLog || return 1

   # Copy pkg-config's pkg.m4 so that our downstream users don't need to.
+  local ac_dir=`aclocal --print-ac-dir`
+  test -s "$ac_dir/dirlist" && ac_dir=$ac_dir:`tr '\n' : < "$ac_dir/dirlist"`
   oIFS=$IFS
   IFS=:
   for dir in \
-    $ACLOCAL_PATH $(aclocal --print-ac-dir) /usr/share/aclocal ''
+    $ACLOCAL_PATH $ac_dir /usr/share/aclocal ''
   do
     IFS=$oIFS
     if test -n "$dir" && test -r "$dir/pkg.m4"; then
-- 
2.6.0

From 7da307031e2d8e66016c67f04afbc543ffd65f16 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email-masked]>
Date: Sat, 17 Oct 2015 13:48:18 -0700
Subject: [PATCH 2/2] gnulib: update to latest; also bootstrap and
 tests/init.sh

* bootstrap: Update from gnulib.
* tests/init.sh: Likewise.
* gnulib: Update submodule to latest.
---
 bootstrap     |  3 ++-
 gnulib        |  2 +-
 tests/init.sh | 22 ++++++++++++++++++++++
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/bootstrap b/bootstrap
index 2fdf267..e72894c 100755
--- a/bootstrap
+++ b/bootstrap
@@ -915,7 +915,8 @@ if test $use_libtool = 1; then
   esac
 fi
 echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
-$gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
+$gnulib_tool $gnulib_tool_options --import $gnulib_modules \
+  || die "gnulib-tool failed"

 for file in $gnulib_files; do
   symlink_to_dir "$GNULIB_SRCDIR" $file \
diff --git a/gnulib b/gnulib
index 5513b40..37c054a 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 5513b40999149090987a0341c018d05d3eea1272
+Subproject commit 37c054af09357276eb560990eba1f20cdc489bfc
diff --git a/tests/init.sh b/tests/init.sh
index 37fc7b6..d366206 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -93,6 +93,27 @@ skip_ () { warn_ "$ME_: skipped test: $@"; Exit 77; }
 fatal_ () { warn_ "$ME_: hard error: $@"; Exit 99; }
 framework_failure_ () { warn_ "$ME_: set-up failure: $@"; Exit 99; }

+# This is used to simplify checking of the return value
+# which is useful when ensuring a command fails as desired.
+# I.e., just doing `command ... &&fail=1` will not catch
+# a segfault in command for example.  With this helper you
+# instead check an explicit exit code like
+#   returns_ 1 command ... || fail
+returns_ () {
+  # Disable tracing so it doesn't interfere with stderr of the wrapped command
+  { set +x; } 2>/dev/null
+
+  local exp_exit="$1"
+  shift
+  "$@"
+  test $? -eq $exp_exit && ret_=0 || ret_=1
+
+  if test "$VERBOSE" = yes && test "$gl_set_x_corrupts_stderr_" = false; then
+    set -x
+  fi
+  { return $ret_; } 2>/dev/null
+}
+
 # Sanitize this shell to POSIX mode, if possible.
 DUALCASE=1; export DUALCASE
 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
@@ -129,6 +150,7 @@ fi
 #  ? - not ok
 gl_shell_test_script_='
 test $(echo y) = y || exit 1
+f_local_() { local v=1; }; f_local_ || exit 1
 score_=10
 if test "$VERBOSE" = yes; then
   test -n "$( (exec 3>&1; set -x; P=1 true 2>&3) 2> /dev/null)" && score_=9
-- 
2.6.0