diff options
author | Denys Vlasenko | 2021-09-07 01:54:23 +0200 |
---|---|---|
committer | Denys Vlasenko | 2021-09-07 02:01:03 +0200 |
commit | f415e21a7dce1d4f4b760fddfaba85c551681e11 (patch) | |
tree | 1c126cfd0ff6193b151db4fddaf79fac3d822dfd /shell/ash_test/ash-misc | |
parent | 41beb53787ec798a27f336c4758cb5ebd8f0c75a (diff) | |
download | busybox-f415e21a7dce1d4f4b760fddfaba85c551681e11.zip busybox-f415e21a7dce1d4f4b760fddfaba85c551681e11.tar.gz |
ash: eval: Do not cache value of eflag in evaltree
Upsteam commit:
Date: Mon, 17 May 2021 15:19:23 +0800
eval: Do not cache value of eflag in evaltree
Patrick BrĂ¼nn <P.Bruenn@beckhoff.com> wrote:
> Since we are migrating to Debian bullseye, we discovered a new behavior
> with our scripts, which look like this:
>>cleanup() {
>> set +e
>> rmdir ""
>>}
>>set -eu
>>trap 'cleanup' EXIT INT TERM
>>echo 'Hello world!'
>
> With old dash v0.5.10.2 this script would return 0 as we expected it.
> But since commit 62cf6955f8abe875752d7163f6f3adbc7e49ebae it returns
> the last exit code of our cleanup function.
...
Thanks for the report. This is actually a fairly old bug with
set -e that's just been exposed by the exit status change. What's
really happening is that cleanup itself is triggering a set -e
exit incorrectly because evaltree cached the value of eflag prior
to the function call.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash_test/ash-misc')
-rw-r--r-- | shell/ash_test/ash-misc/exitcode_trap7.right | 2 | ||||
-rwxr-xr-x | shell/ash_test/ash-misc/exitcode_trap7.tests | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/shell/ash_test/ash-misc/exitcode_trap7.right b/shell/ash_test/ash-misc/exitcode_trap7.right new file mode 100644 index 0000000..07d66e9 --- /dev/null +++ b/shell/ash_test/ash-misc/exitcode_trap7.right @@ -0,0 +1,2 @@ +Start +Ok:0 diff --git a/shell/ash_test/ash-misc/exitcode_trap7.tests b/shell/ash_test/ash-misc/exitcode_trap7.tests new file mode 100755 index 0000000..9772a7b --- /dev/null +++ b/shell/ash_test/ash-misc/exitcode_trap7.tests @@ -0,0 +1,7 @@ +$THIS_SH -c ' +cleanup() { set +e; false; } +set -eu +trap cleanup EXIT +echo Start +' +echo Ok:$? |