[libvirt] [PATCH] autobuild.sh: avoid bashism

* autobuild.sh: Replace 'set -o pipefail' with POSIX alternative. Reported by Matthias Bolte. --- On IRC, Matthias pointed out that his testing of my recent autobuild.sh patch triggered a dash failure. Unfortunately, the checkbashisms script is not smart enough to realize that 'set -o pipefail' is a bashism, yet it also does not provide a bug reporting address in checkbashisms --help :( autobuild.sh | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/autobuild.sh b/autobuild.sh index 4de5af8..66ba132 100755 --- a/autobuild.sh +++ b/autobuild.sh @@ -35,9 +35,15 @@ esac make make install -set -o pipefail -make check 2>&1 | tee "$RESULTS" -make syntax-check 2>&1 | tee -a "$RESULTS" +# set -o pipefail is a bashism; this use of exec is the POSIX alternative +exec 3>&1 +st=$( + exec 4>&1 >&3 + { make check syntax-check 2>&1; echo $? >&4; } \ + | tee "$RESULTS" +) +exec 3>&- +test $st = 0 test -x /usr/bin/lcov && make cov rm -f *.tar.gz -- 1.7.0.1

2010/6/4 Eric Blake <eblake@redhat.com>:
* autobuild.sh: Replace 'set -o pipefail' with POSIX alternative. Reported by Matthias Bolte. ---
On IRC, Matthias pointed out that his testing of my recent autobuild.sh patch triggered a dash failure. Unfortunately, the checkbashisms script is not smart enough to realize that 'set -o pipefail' is a bashism, yet it also does not provide a bug reporting address in checkbashisms --help :(
autobuild.sh | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/autobuild.sh b/autobuild.sh index 4de5af8..66ba132 100755 --- a/autobuild.sh +++ b/autobuild.sh @@ -35,9 +35,15 @@ esac make make install
-set -o pipefail -make check 2>&1 | tee "$RESULTS" -make syntax-check 2>&1 | tee -a "$RESULTS" +# set -o pipefail is a bashism; this use of exec is the POSIX alternative +exec 3>&1 +st=$( + exec 4>&1 >&3 + { make check syntax-check 2>&1; echo $? >&4; } \ + | tee "$RESULTS" +) +exec 3>&- +test $st = 0 test -x /usr/bin/lcov && make cov
rm -f *.tar.gz -- 1.7.0.1
ACK, tested and verified that it fixes the problem. Matthias

On 06/04/2010 09:49 AM, Matthias Bolte wrote:
-set -o pipefail -make check 2>&1 | tee "$RESULTS" -make syntax-check 2>&1 | tee -a "$RESULTS" +# set -o pipefail is a bashism; this use of exec is the POSIX alternative +exec 3>&1 +st=$( + exec 4>&1 >&3 + { make check syntax-check 2>&1; echo $? >&4; } \ + | tee "$RESULTS" +)
Technically, to be identical to the earlier version, I would have to use: st=$( exec 4>&1 >&3 3>&- { make check syntax-check 2>&1 4>&-; echo $? >&4; } \ | tee "$RESULTS" 4>&- ) but leaking fd 3 and 4 to make and tee didn't bother me.
ACK, tested and verified that it fixes the problem.
Thanks; pushed. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Matthias Bolte