[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Fix exit status of signal handlers in shell scripts
From: |
Bruno Haible |
Subject: |
Re: [PATCH] Fix exit status of signal handlers in shell scripts |
Date: |
Sun, 31 Jan 2010 02:09:38 +0100 |
User-agent: |
KMail/1.9.9 |
Dmitry V. Levin wrote:
> This would break the "If removal fails" statement.
> Let's pass exit code to this function as an argument:
>
> remove_tmp_()
> {
> __st=$1
> [...]
> trap 'remove_tmp_ $?' 0
Yes, you're right. Here's an updated proposed patch:
2010-01-30 Bruno Haible <address@hidden>
Dmitry V. Levin <address@hidden>
Avoid unportable use of $? at the beginning of a shell function.
* tests/init.sh (remove_tmp_): Don't retrieve the exit status here.
(setup_): Do it directly in the trap handler here.
--- tests/init.sh.orig Sun Jan 31 02:07:31 2010
+++ tests/init.sh Sun Jan 31 02:07:10 2010
@@ -79,10 +79,10 @@
testdir_prefix_() { printf gt; }
# Run the user-overridable cleanup_ function, remove the temporary
-# directory and exit with the incoming value of $?.
+# directory and exit with the code passed as first argument.
remove_tmp_()
{
- __st=$?
+ __st=$1
cleanup_
# cd out of the directory we're about to remove
cd "$initial_cwd_" || cd / || cd /tmp
@@ -127,7 +127,7 @@
# This pair of trap statements ensures that the temporary directory,
# $test_dir_, is removed upon exit as well as upon catchable signal.
- trap remove_tmp_ 0
+ trap 'remove_tmp_ $?' 0
trap 'Exit $?' 1 2 13 15
}
- Re: [PATCH] Fix exit status of signal handlers in shell scripts, (continued)
Re: [PATCH] Fix exit status of signal handlers in shell scripts, Bruno Haible, 2010/01/30
Re: [PATCH] Fix exit status of signal handlers in shell scripts, Bruno Haible, 2010/01/30
Re: [PATCH] Fix exit status of signal handlers in shell scripts, Bruno Haible, 2010/01/30
Re: [PATCH] Fix exit status of signal handlers in shell scripts, Bruno Haible, 2010/01/30
Re: [PATCH] Fix exit status of signal handlers in shell scripts, Ralf Wildenhues, 2010/01/31