coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[coreutils] [PATCH] init.sh: work around trap limitation of some shells


From: Paul Eggert
Subject: [coreutils] [PATCH] init.sh: work around trap limitation of some shells
Date: Tue, 03 Aug 2010 13:03:15 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.11) Gecko/20100713 Thunderbird/3.0.6

Hmm, maybe bootstrap should copy gnulib-tests/init.sh to
tests/init.sh so that we don't have to do this stuff by hand?

>From 13fbe90cf4008ae30625bcfd857201963ff273d5 Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Tue, 3 Aug 2010 13:01:16 -0700
Subject: [PATCH] init.sh: work around trap limitation of some shells

* tests/init.sh (setup_): Move exit trap outside of shell function.
This patch is imported from gnulib.
---
 tests/init.sh |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/init.sh b/tests/init.sh
index 7943526..bc82d69 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -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
-- 
1.7.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]