I noticed that when the test-c-stack2.sh test is skipped, it leaves behind its temporary file.
I propose to fix it by adding a trap ... 0. A welcome side-effect is that with this change, you remove temporary files from only one place: the trap, rather than just prior to every other exit point. The only tricky part about the trap-0 is that you have to be sure to preserve the exit status. Here's the patch for that particular file: diff --git a/tests/test-c-stack2.sh b/tests/test-c-stack2.sh index a80373d..88c3136 100755 --- a/tests/test-c-stack2.sh +++ b/tests/test-c-stack2.sh @@ -1,7 +1,8 @@ #!/bin/sh tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 tmpfiles="t-c-stack2.tmp" @@ -31,6 +32,4 @@ else (exit 1); exit 1 fi -rm -fr $tmpfiles - exit 0 However, that is an idiom repeated in many other files: $ git grep -l 'trap .rm -fr .tmpfiles. 1 2 3 15' tests/test-atexit.sh tests/test-binary-io.sh tests/test-c-stack.sh tests/test-closein.sh tests/test-dprintf-posix.sh tests/test-fprintf-posix.sh tests/test-lseek.sh tests/test-perror.sh tests/test-printf-posix.sh tests/test-select-in.sh tests/test-select-out.sh tests/test-sigpipe.sh tests/test-tsearch.sh tests/test-vdprintf-posix.sh tests/test-vfprintf-posix.sh tests/test-vprintf-posix.sh tests/test-xprintf-posix.sh tests/test-xstrtoimax.sh tests/test-xstrtol.sh tests/test-xstrtoumax.sh tests/test-yesno.sh tests/uniwidth/test-uc_width2.sh So below I've included a patch to correct all of those, too, using this script: cat <<EOF > test-trap-convert eval '(exit $?0)' && eval 'exec perl -wS -ni "$0" ${1+"$@"}' & eval 'exec perl -wS -ni "$0" $argv:q' if 0; use strict; use warnings; my $rpl = <<'EOF'; trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 EOF /^\# Cleanup$/ and next; /(.*) \{ rm -[fr]+ \$tmpfiles; (exit 1); \}$/ and (print "$1 $2\n"), next; /(.*) rm -[fr]+ \$tmpfiles; (exit 1)$/ and (print "$1 $2\n"), next; /(.*) rm -[fr]+ \$tmpfiles; (exit 1;.*)/ and (print "$1 $2;"), next; /^trap.*15$/ and (print $rpl), next; /^\s*rm -[fr]+ \$tmpfiles$/ and next; print; EOF chmod a+x test-trap-convert I ran it like this: grep -l 'trap .rm -fr .tmpfiles. 1 2 3 15'|xargs ./test-trap-convert It's not perfect, because it leaves a few pairs of adjacent blank lines, but that's easy to fix. I did it with this: $ perl -pi -0777 -e 's/\n\n\n+/\n\n/g' $(git ls-files -m) Oops. There's one more nit: there were two now-dangling "# Cleanup" comments. So I went back, tweaked the script to remove those, too, and reran things. Here's the result. Any objections? Note that the initial regexp by which I selected the files to update is very strict. I'd be surprised if it can't be relaxed to catch more, but I'd like to limit this first pass to those changes I've already reviewed (visually, and partially tested) a few times. >From ccfa387893628de405055d2ec69ee2f07094424d Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@redhat.com> Date: Sat, 14 Nov 2009 12:24:21 +0100 Subject: [PATCH] tests: use a better trap idiom --- tests/test-atexit.sh | 5 ++--- tests/test-binary-io.sh | 5 ++--- tests/test-c-stack.sh | 5 ++--- tests/test-c-stack2.sh | 5 ++--- tests/test-closein.sh | 6 ++---- tests/test-dprintf-posix.sh | 5 ++--- tests/test-fprintf-posix.sh | 5 ++--- tests/test-lseek.sh | 4 ++-- tests/test-perror.sh | 10 +++++----- tests/test-printf-posix.sh | 5 ++--- tests/test-select-in.sh | 5 ++--- tests/test-select-out.sh | 5 ++--- tests/test-sigpipe.sh | 10 +++++----- tests/test-tsearch.sh | 7 +++---- tests/test-vdprintf-posix.sh | 5 ++--- tests/test-vfprintf-posix.sh | 5 ++--- tests/test-vprintf-posix.sh | 5 ++--- tests/test-xprintf-posix.sh | 9 ++++----- tests/test-xstrtoimax.sh | 5 ++--- tests/test-xstrtol.sh | 5 ++--- tests/test-xstrtoumax.sh | 5 ++--- tests/test-yesno.sh | 6 ++---- tests/uniwidth/test-uc_width2.sh | 5 ++--- 23 files changed, 55 insertions(+), 77 deletions(-) diff --git a/tests/test-atexit.sh b/tests/test-atexit.sh index 49c7729..541fb24 100755 --- a/tests/test-atexit.sh +++ b/tests/test-atexit.sh @@ -1,7 +1,8 @@ #!/bin/sh tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 tmpfiles="$tmpfiles t-atexit.tmp" # Check that an atexit handler is called when main() returns normally. @@ -27,6 +28,4 @@ if test -f t-atexit.tmp; then exit 1 fi -rm -fr $tmpfiles - exit 0 diff --git a/tests/test-binary-io.sh b/tests/test-binary-io.sh index 33e128c..5a30b41 100755 --- a/tests/test-binary-io.sh +++ b/tests/test-binary-io.sh @@ -1,11 +1,10 @@ #!/bin/sh tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 tmpfiles="$tmpfiles t-bin-out1.tmp t-bin-out2.tmp" ./test-binary-io${EXEEXT} > t-bin-out1.tmp || exit 1 -rm -fr $tmpfiles - exit 0 diff --git a/tests/test-c-stack.sh b/tests/test-c-stack.sh index f979065..cb6bea4 100755 --- a/tests/test-c-stack.sh +++ b/tests/test-c-stack.sh @@ -1,7 +1,8 @@ #!/bin/sh tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 tmpfiles="t-c-stack.tmp" ./test-c-stack${EXEEXT} 2> t-c-stack.tmp @@ -16,6 +17,4 @@ else (exit 1); exit 1 fi -rm -fr $tmpfiles - exit 0 diff --git a/tests/test-c-stack2.sh b/tests/test-c-stack2.sh index a80373d..88c3136 100755 --- a/tests/test-c-stack2.sh +++ b/tests/test-c-stack2.sh @@ -1,7 +1,8 @@ #!/bin/sh tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 tmpfiles="t-c-stack2.tmp" @@ -31,6 +32,4 @@ else (exit 1); exit 1 fi -rm -fr $tmpfiles - exit 0 diff --git a/tests/test-closein.sh b/tests/test-closein.sh index a75929a..02d3b47 100755 --- a/tests/test-closein.sh +++ b/tests/test-closein.sh @@ -1,7 +1,8 @@ #!/bin/sh tmpfiles= -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 p=t-closein- tmpfiles="${p}in.tmp ${p}xout.tmp ${p}out1.tmp ${p}out2.tmp" @@ -32,7 +33,4 @@ cat ${p}in.tmp 2>/dev/null | ./test-closein${EXEEXT} consume || exit 1 # Test for error when read fails because no file available ./test-closein${EXEEXT} consume close <&- 2>/dev/null && exit 1 -# Cleanup -rm -fr $tmpfiles - exit 0 diff --git a/tests/test-dprintf-posix.sh b/tests/test-dprintf-posix.sh index 75c3593..9416c63 100755 --- a/tests/test-dprintf-posix.sh +++ b/tests/test-dprintf-posix.sh @@ -1,7 +1,8 @@ #!/bin/sh tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 tmpfiles="$tmpfiles t-dprintf-posix.tmp t-dprintf-posix.out" ./test-dprintf-posix${EXEEXT} > t-dprintf-posix.tmp || exit 1 @@ -11,6 +12,4 @@ LC_ALL=C tr -d '\r' < t-dprintf-posix.tmp > t-dprintf-posix.out || exit 1 ${DIFF} "${srcdir}/test-printf-posix.output" t-dprintf-posix.out result=$? -rm -fr $tmpfiles - exit $result diff --git a/tests/test-fprintf-posix.sh b/tests/test-fprintf-posix.sh index f9acf1f..292d018 100755 --- a/tests/test-fprintf-posix.sh +++ b/tests/test-fprintf-posix.sh @@ -1,7 +1,8 @@ #!/bin/sh tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 tmpfiles="$tmpfiles t-fprintf-posix.tmp t-fprintf-posix.out" ./test-fprintf-posix${EXEEXT} > t-fprintf-posix.tmp || exit 1 @@ -11,6 +12,4 @@ LC_ALL=C tr -d '\r' < t-fprintf-posix.tmp > t-fprintf-posix.out || exit 1 ${DIFF} "${srcdir}/test-printf-posix.output" t-fprintf-posix.out result=$? -rm -fr $tmpfiles - exit $result diff --git a/tests/test-lseek.sh b/tests/test-lseek.sh index e84c2bb..c679a22 100755 --- a/tests/test-lseek.sh +++ b/tests/test-lseek.sh @@ -1,7 +1,8 @@ #!/bin/sh tmpfiles= -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 tmpfiles=t-lseek.tmp # seekable files @@ -13,5 +14,4 @@ echo hi | ./test-lseek${EXEEXT} 1 | cat || exit 1 # closed descriptors ./test-lseek${EXEEXT} 2 <&- >&- || exit 1 -rm -rf $tmpfiles exit 0 diff --git a/tests/test-perror.sh b/tests/test-perror.sh index f2c8fdc..b6780ad 100755 --- a/tests/test-perror.sh +++ b/tests/test-perror.sh @@ -1,27 +1,27 @@ #!/bin/sh tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 # Test NULL prefix. Result should not contain a number. tmpfiles="$tmpfiles t-perror.tmp" ./test-perror${EXEEXT} 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror.tmp if grep '[0-9]' t-perror.tmp > /dev/null; then - rm -fr $tmpfiles; exit 1 + exit 1 fi # Test empty prefix. Result should be the same. tmpfiles="$tmpfiles t-perror1.tmp" ./test-perror${EXEEXT} '' 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror1.tmp diff t-perror.tmp t-perror1.tmp -test $? = 0 || { rm -fr $tmpfiles; exit 1; } +test $? = 0 || exit 1 # Test non-empty prefix. tmpfiles="$tmpfiles t-perror2.tmp t-perror3.tmp" ./test-perror${EXEEXT} 'foo' 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror3.tmp sed -e 's/^/foo: /' < t-perror.tmp > t-perror2.tmp diff t-perror2.tmp t-perror3.tmp -test $? = 0 || { rm -fr $tmpfiles; exit 1; } +test $? = 0 || exit 1 -rm -fr $tmpfiles exit 0 diff --git a/tests/test-printf-posix.sh b/tests/test-printf-posix.sh index a812345..dbed233 100755 --- a/tests/test-printf-posix.sh +++ b/tests/test-printf-posix.sh @@ -1,7 +1,8 @@ #!/bin/sh tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 tmpfiles="$tmpfiles t-printf-posix.tmp t-printf-posix.out" ./test-printf-posix${EXEEXT} > t-printf-posix.tmp || exit 1 @@ -11,6 +12,4 @@ LC_ALL=C tr -d '\r' < t-printf-posix.tmp > t-printf-posix.out || exit 1 ${DIFF} "${srcdir}/test-printf-posix.output" t-printf-posix.out result=$? -rm -fr $tmpfiles - exit $result diff --git a/tests/test-select-in.sh b/tests/test-select-in.sh index 13f6bbb..50bdc4a 100755 --- a/tests/test-select-in.sh +++ b/tests/test-select-in.sh @@ -5,7 +5,8 @@ # of /dev/null. tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 tmpfiles="$tmpfiles t-select-in.tmp" @@ -32,6 +33,4 @@ rm -f t-select-in.tmp ./test-select-fd${EXEEXT} r 0 t-select-in.tmp < /dev/null test `cat t-select-in.tmp` = "1" || exit 1 -rm -fr $tmpfiles - exit 0 diff --git a/tests/test-select-out.sh b/tests/test-select-out.sh index c5fd861..c71ceaf 100755 --- a/tests/test-select-out.sh +++ b/tests/test-select-out.sh @@ -2,7 +2,8 @@ # Test select() on file descriptors opened for writing. tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 tmpfiles="$tmpfiles t-select-out.out t-select-out.tmp" @@ -30,6 +31,4 @@ rm -f t-select-out.tmp ./test-select-fd${EXEEXT} w 1 t-select-out.tmp > /dev/null test `cat t-select-out.tmp` = "1" || exit 1 -rm -fr $tmpfiles - exit 0 diff --git a/tests/test-sigpipe.sh b/tests/test-sigpipe.sh index bc2baf2..2dc1c9a 100755 --- a/tests/test-sigpipe.sh +++ b/tests/test-sigpipe.sh @@ -1,14 +1,15 @@ #!/bin/sh tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 # Test signal's default behaviour. tmpfiles="$tmpfiles t-sigpipeA.tmp" ./test-sigpipe${EXEEXT} A 2> t-sigpipeA.tmp | head -1 > /dev/null if test -s t-sigpipeA.tmp; then LC_ALL=C tr -d '\r' < t-sigpipeA.tmp - rm -fr $tmpfiles; exit 1 + exit 1 fi # Test signal's ignored behaviour. @@ -16,7 +17,7 @@ tmpfiles="$tmpfiles t-sigpipeB.tmp" ./test-sigpipe${EXEEXT} B 2> t-sigpipeB.tmp | head -1 > /dev/null if test -s t-sigpipeB.tmp; then LC_ALL=C tr -d '\r' < t-sigpipeB.tmp - rm -fr $tmpfiles; exit 1 + exit 1 fi # Test signal's behaviour when a handler is installed. @@ -24,8 +25,7 @@ tmpfiles="$tmpfiles t-sigpipeC.tmp" ./test-sigpipe${EXEEXT} B 2> t-sigpipeC.tmp | head -1 > /dev/null if test -s t-sigpipeC.tmp; then LC_ALL=C tr -d '\r' < t-sigpipeC.tmp - rm -fr $tmpfiles; exit 1 + exit 1 fi -rm -fr $tmpfiles exit 0 diff --git a/tests/test-tsearch.sh b/tests/test-tsearch.sh index c206956..fb09b5c 100755 --- a/tests/test-tsearch.sh +++ b/tests/test-tsearch.sh @@ -1,12 +1,11 @@ #!/bin/sh tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 tmpfiles="$tmpfiles t-tsearch.out" ./test-tsearch${EXEEXT} > t-tsearch.out 2>&1 -test $? = 0 || { cat t-tsearch.out 1>&2; rm -f $tmpfiles; exit 1; } - -rm -f $tmpfiles +test $? = 0 || { cat t-tsearch.out 1>&2; exit 1; }; exit 0 diff --git a/tests/test-vdprintf-posix.sh b/tests/test-vdprintf-posix.sh index 558c41d..d3103b1 100755 --- a/tests/test-vdprintf-posix.sh +++ b/tests/test-vdprintf-posix.sh @@ -1,7 +1,8 @@ #!/bin/sh tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 tmpfiles="$tmpfiles t-vdprintf-posix.tmp t-vdprintf-posix.out" ./test-vdprintf-posix${EXEEXT} > t-vdprintf-posix.tmp || exit 1 @@ -11,6 +12,4 @@ LC_ALL=C tr -d '\r' < t-vdprintf-posix.tmp > t-vdprintf-posix.out || exit 1 ${DIFF} "${srcdir}/test-printf-posix.output" t-vdprintf-posix.out result=$? -rm -fr $tmpfiles - exit $result diff --git a/tests/test-vfprintf-posix.sh b/tests/test-vfprintf-posix.sh index 74339ba..58c6801 100755 --- a/tests/test-vfprintf-posix.sh +++ b/tests/test-vfprintf-posix.sh @@ -1,7 +1,8 @@ #!/bin/sh tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 tmpfiles="$tmpfiles t-vfprintf-posix.tmp t-vfprintf-posix.out" ./test-vfprintf-posix${EXEEXT} > t-vfprintf-posix.tmp || exit 1 @@ -11,6 +12,4 @@ LC_ALL=C tr -d '\r' < t-vfprintf-posix.tmp > t-vfprintf-posix.out || exit 1 ${DIFF} "${srcdir}/test-printf-posix.output" t-vfprintf-posix.out result=$? -rm -fr $tmpfiles - exit $result diff --git a/tests/test-vprintf-posix.sh b/tests/test-vprintf-posix.sh index 968a8b2..ecce39d 100755 --- a/tests/test-vprintf-posix.sh +++ b/tests/test-vprintf-posix.sh @@ -1,7 +1,8 @@ #!/bin/sh tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 tmpfiles="$tmpfiles t-vprintf-posix.tmp t-vprintf-posix.out" ./test-vprintf-posix${EXEEXT} > t-vprintf-posix.tmp || exit 1 @@ -11,6 +12,4 @@ LC_ALL=C tr -d '\r' < t-vprintf-posix.tmp > t-vprintf-posix.out || exit 1 ${DIFF} "${srcdir}/test-printf-posix.output" t-vprintf-posix.out result=$? -rm -fr $tmpfiles - exit $result diff --git a/tests/test-xprintf-posix.sh b/tests/test-xprintf-posix.sh index 0087a9d..23f0d04 100755 --- a/tests/test-xprintf-posix.sh +++ b/tests/test-xprintf-posix.sh @@ -1,7 +1,8 @@ #!/bin/sh tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 tmpfiles="$tmpfiles t-xprintf-posix.tmp t-xprintf-posix.out" ./test-xprintf-posix${EXEEXT} > t-xprintf-posix.tmp || exit 1 @@ -9,7 +10,7 @@ LC_ALL=C tr -d '\r' < t-xprintf-posix.tmp > t-xprintf-posix.out || exit 1 : ${DIFF=diff} ${DIFF} "${srcdir}/test-printf-posix.output" t-xprintf-posix.out -test $? = 0 || { rm -fr $tmpfiles; exit 1; } +test $? = 0 || exit 1 tmpfiles="$tmpfiles t-xfprintf-posix.tmp t-xfprintf-posix.out" ./test-xfprintf-posix${EXEEXT} > t-xfprintf-posix.tmp || exit 1 @@ -17,8 +18,6 @@ LC_ALL=C tr -d '\r' < t-xfprintf-posix.tmp > t-xfprintf-posix.out || exit 1 : ${DIFF=diff} ${DIFF} "${srcdir}/test-printf-posix.output" t-xfprintf-posix.out -test $? = 0 || { rm -fr $tmpfiles; exit 1; } - -rm -fr $tmpfiles +test $? = 0 || exit 1 exit 0 diff --git a/tests/test-xstrtoimax.sh b/tests/test-xstrtoimax.sh index e6a5e5d..2b720b5 100755 --- a/tests/test-xstrtoimax.sh +++ b/tests/test-xstrtoimax.sh @@ -1,7 +1,8 @@ #!/bin/sh tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 tmpfiles="t-xstrtoimax.tmp t-xstrtoimax.xo" : > t-xstrtoimax.tmp @@ -46,6 +47,4 @@ EOF diff t-xstrtoimax.xo t-xstrtoimax.tmp || result=1 -rm -fr $tmpfiles - exit $result diff --git a/tests/test-xstrtol.sh b/tests/test-xstrtol.sh index c56c675..6e8c6b2 100755 --- a/tests/test-xstrtol.sh +++ b/tests/test-xstrtol.sh @@ -1,7 +1,8 @@ #!/bin/sh tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 tmpfiles="t-xstrtol.tmp t-xstrtol.xo" : > t-xstrtol.tmp @@ -67,6 +68,4 @@ EOF diff t-xstrtol.xo t-xstrtol.tmp || result=1 -rm -fr $tmpfiles - exit $result diff --git a/tests/test-xstrtoumax.sh b/tests/test-xstrtoumax.sh index 12a7ba9..2564f81 100755 --- a/tests/test-xstrtoumax.sh +++ b/tests/test-xstrtoumax.sh @@ -1,7 +1,8 @@ #!/bin/sh tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 tmpfiles="t-xstrtoumax.tmp t-xstrtoumax.xo" : > t-xstrtoumax.tmp @@ -46,6 +47,4 @@ EOF diff t-xstrtoumax.xo t-xstrtoumax.tmp || result=1 -rm -fr $tmpfiles - exit $result diff --git a/tests/test-yesno.sh b/tests/test-yesno.sh index b1a5b65..778ea30 100755 --- a/tests/test-yesno.sh +++ b/tests/test-yesno.sh @@ -1,7 +1,8 @@ #!/bin/sh tmpfiles= -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 p=t-yesno- tmpfiles="${p}in.tmp ${p}xout.tmp ${p}out1.tmp ${p}out.tmp ${p}err.tmp" @@ -68,7 +69,4 @@ LC_ALL=C tr -d "$cr" < ${p}out1.tmp > ${p}out.tmp || exit 1 cmp ${p}xout.tmp ${p}out.tmp || exit 1 test -s ${p}err.tmp || exit 1 -# Cleanup -rm -fr $tmpfiles - exit 0 diff --git a/tests/uniwidth/test-uc_width2.sh b/tests/uniwidth/test-uc_width2.sh index 484288c..4e762c5 100755 --- a/tests/uniwidth/test-uc_width2.sh +++ b/tests/uniwidth/test-uc_width2.sh @@ -1,7 +1,8 @@ #!/bin/sh tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0 +trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15 tmpfiles="$tmpfiles uc_width.out" ./test-uc_width2${EXEEXT} | LC_ALL=C tr -d '\r' > uc_width.out @@ -377,6 +378,4 @@ EOF ${DIFF} uc_width.ok uc_width.out result=$? -rm -fr $tmpfiles - exit $result -- 1.6.5.2.372.gc0502