init.sh: work around trap limitation of some shells
authorPeter O'Gorman <pogma@thewrittenword.com>
Thu, 29 Jul 2010 21:14:59 +0000 (15:14 -0600)
committerEric Blake <eblake@redhat.com>
Thu, 29 Jul 2010 21:33:01 +0000 (15:33 -0600)
This limitation is already documented in the Autoconf manual.

* tests/init.sh (setup_): Move exit trap outside of shell function.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
tests/init.sh

index 8051cf0..0535e28 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-07-29  Peter O'Gorman  <pogma@thewrittenword.com>  (tiny change)
+
+       init.sh: work around trap limitation of some shells
+       * tests/init.sh (setup_): Move exit trap outside of shell function.
+
 2010-07-29  Eric Blake  <eblake@redhat.com>
 
        strtod: aid debugging
index 7943526..bc82d69 100644 (file)
@@ -255,9 +255,9 @@ setup_()
     || fail_ "failed to create temporary directory in $initial_cwd_"
   cd "$test_dir_"
 
-  # These trap statements ensure that the temporary directory, $test_dir_,
-  # is removed upon exit as well as upon receipt of any of the listed signals.
-  trap remove_tmp_ 0
+  # This trap statement, along with a trap on 0 below, ensure that the
+  # temporary directory, $test_dir_, is removed upon exit as well as
+  # upon receipt of any of the listed signals.
   for sig_ in 1 2 3 13 15; do
     eval "trap 'Exit $(expr $sig_ + 128)' $sig_"
   done
@@ -385,3 +385,6 @@ test -f "$srcdir/init.cfg" \
   && . "$srcdir/init.cfg"
 
 setup_ "$@"
+# This trap is here, rather than in the setup_ function, because some
+# shells run the exit trap at shell function exit, rather than script exit.
+trap remove_tmp_ 0