From aa9f1d090454845b6b32a16009861eddfaf3014c Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 22 Dec 2011 13:12:19 +0100 Subject: [PATCH] init.sh: correct previous change MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * tests/init.sh (compare): My previous change was wrong. Don't clobber "$?". Spotted by Stefano Lattarini and Pádraig Brady. --- ChangeLog | 4 ++++ tests/init.sh | 16 +++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index df1f5b540..7ca5e7b75 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2011-12-22 Jim Meyering + init.sh: correct previous change + * tests/init.sh (compare): My previous change was wrong. + Don't clobber "$?". Spotted by Stefano Lattarini and Pádraig Brady. + init.sh: avoid unwarranted test failure when using "set -e" * tests/init.sh (compare): Ignore nonzero exit from compare_dev_null_. Otherwise, in a test script that uses "set -e" (like many in vc-dwim) diff --git a/tests/init.sh b/tests/init.sh index 458a44862..1e1f0e366 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -304,11 +304,17 @@ fi # Otherwise, propagate $? to caller: any diffs have already been printed. compare () { - compare_dev_null_ "$@" || : - case $? in - 0|1) return $?;; - *) compare_ "$@";; - esac + # This looks like it can be factored to use a simple "case $?" + # after unchecked compare_dev_null_ invocation, but that would + # fail in a "set -e" environment. + if compare_dev_null_ "$@"; then + return 0 + else + case $? in + 1) return 1;; + *) compare_ "$@";; + esac + fi } # An arbitrary prefix to help distinguish test directories. -- 2.11.0