From: Rob Browning Date: Sat, 2 Nov 2013 17:55:49 +0000 (-0500) Subject: Set pipefail so that "x | y || exit $?" will work properly. X-Git-Tag: 0.25-rc4~28 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=56db423eadcf2f57ef0af2523010a1748ac4fbae Set pipefail so that "x | y || exit $?" will work properly. Set pipefail so that constructs like this will work properly: x | y | z || exit $? or WVPASS x | WVPASS y | WVPASS z || exit $? Signed-off-by: Rob Browning --- diff --git a/cmd/import-rdiff-backup-cmd.sh b/cmd/import-rdiff-backup-cmd.sh index 98dd21b..b86404d 100755 --- a/cmd/import-rdiff-backup-cmd.sh +++ b/cmd/import-rdiff-backup-cmd.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -o pipefail + must() { local file=${BASH_SOURCE[0]} local line=${BASH_LINENO[0]} diff --git a/t/test-cat-file.sh b/t/test-cat-file.sh index f0d7ebe..c8d148a 100755 --- a/t/test-cat-file.sh +++ b/t/test-cat-file.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash . ./wvtest-bup.sh +set -o pipefail + top="$(WVPASS pwd)" || exit $? tmpdir="$(WVPASS wvmktempdir)" || exit $? diff --git a/t/test-command-without-init-fails.sh b/t/test-command-without-init-fails.sh index 3c5a0cd..2294bdf 100755 --- a/t/test-command-without-init-fails.sh +++ b/t/test-command-without-init-fails.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash . ./wvtest-bup.sh +set -o pipefail + WVSTART 'all' top="$(WVPASS pwd)" || exit $? diff --git a/t/test-index-check-device.sh b/t/test-index-check-device.sh index 08b2aa7..23dbb77 100755 --- a/t/test-index-check-device.sh +++ b/t/test-index-check-device.sh @@ -2,6 +2,8 @@ . ./wvtest-bup.sh . ./t/lib.sh +set -o pipefail + if [ $(t/root-status) != root ]; then echo 'Not root: skipping --check-device tests.' exit 0 # FIXME: add WVSKIP. diff --git a/t/test-meta.sh b/t/test-meta.sh index 879e108..bb0cdef 100755 --- a/t/test-meta.sh +++ b/t/test-meta.sh @@ -2,7 +2,9 @@ . wvtest.sh . t/lib.sh -TOP="$(pwd)" +set -o pipefail + +TOP="$(WVPASS pwd)" || exit $? export BUP_DIR="$TOP/buptest.tmp" bup() diff --git a/t/test-redundant-saves.sh b/t/test-redundant-saves.sh index 145994a..d8cceac 100755 --- a/t/test-redundant-saves.sh +++ b/t/test-redundant-saves.sh @@ -11,6 +11,8 @@ . ./wvtest-bup.sh +set -o pipefail + WVSTART 'all' top="$(pwd)" diff --git a/t/test-restore-single-file.sh b/t/test-restore-single-file.sh index 86df67f..c67701b 100755 --- a/t/test-restore-single-file.sh +++ b/t/test-restore-single-file.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash . ./wvtest-bup.sh +set -o pipefail + WVSTART 'all' top="$(WVPASS pwd)" || exit $? diff --git a/t/test-rm-between-index-and-save.sh b/t/test-rm-between-index-and-save.sh index ce03bef..31b6f3b 100755 --- a/t/test-rm-between-index-and-save.sh +++ b/t/test-rm-between-index-and-save.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash . ./wvtest-bup.sh +set -o pipefail + top="$(WVPASS pwd)" || exit $? tmpdir="$(WVPASS wvmktempdir)" || exit $? export BUP_DIR="$tmpdir/bup" diff --git a/t/test.sh b/t/test.sh index 3f96ab0..7f7a2e0 100755 --- a/t/test.sh +++ b/t/test.sh @@ -2,6 +2,8 @@ . wvtest.sh . t/lib.sh +set -o pipefail + TOP="$(WVPASS /bin/pwd)" || exit $? export BUP_DIR="$TOP/buptest.tmp" @@ -165,7 +167,8 @@ WVPASS bup split -t t/testfile2 --fanout 3 >tags2tf.tmp WVPASS bup split -r "$BUP_DIR" -c t/testfile2 >tags2c.tmp WVPASS bup split -r :$BUP_DIR -c t/testfile2 >tags2c.tmp WVPASS ls -lR \ - | WVPASS bup split -r :$BUP_DIR -c --fanout 3 --max-pack-objects 3 -n lslr + | WVPASS bup split -r :$BUP_DIR -c --fanout 3 --max-pack-objects 3 -n lslr \ + || exit $? WVPASS bup ls WVFAIL bup ls /does-not-exist WVPASS bup ls /lslr @@ -212,7 +215,7 @@ WVSTART "save/git-fsck" (WVPASS cd "$TOP/t/sampledata" && WVPASS bup save -vvn master /) || exit $? result="$(git fsck --full --strict 2>&1)" || exit $? n=$(echo "$result" | - egrep -v 'dangling (commit|tree|blob)' | + WVFAIL egrep -v 'dangling (commit|tree|blob)' | WVPASS tee -a /dev/stderr | WVPASS wc -l) || exit $? WVPASS [ "$n" -eq 0 ]