diff options
author | dumbbell <dumbbell@FreeBSD.org> | 2012-01-16 11:07:46 +0000 |
---|---|---|
committer | dumbbell <dumbbell@FreeBSD.org> | 2012-01-16 11:07:46 +0000 |
commit | 8b387a2d35f960b0b880a2b1863250d6a9b4d692 (patch) | |
tree | 5791a3a058bf56e166a4607a77c3912f992892ea /tools | |
parent | 4e22d62dd60e215d56c8fe89a74171b4c90d3f2e (diff) | |
download | FreeBSD-src-8b387a2d35f960b0b880a2b1863250d6a9b4d692.zip FreeBSD-src-8b387a2d35f960b0b880a2b1863250d6a9b4d692.tar.gz |
sh: Fix execution of multiple statements in a trap when evalskip is set
Before this fix, only the first statement of the trap was executed if
evalskip was set. This is for example the case when:
o "-e" is set for this shell
o a trap is set on EXIT
o a function returns 1 and causes the script to abort
Reviewed by: jilles
MFC after: 2 weeks
Diffstat (limited to 'tools')
-rw-r--r-- | tools/regression/bin/sh/builtins/trap10.0 | 6 | ||||
-rw-r--r-- | tools/regression/bin/sh/builtins/trap11.0 | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/builtins/trap10.0 b/tools/regression/bin/sh/builtins/trap10.0 new file mode 100644 index 0000000..fa0e35d --- /dev/null +++ b/tools/regression/bin/sh/builtins/trap10.0 @@ -0,0 +1,6 @@ +# $FreeBSD$ + +# Check that the return statement will not break the EXIT trap, ie. all +# trap commands are executed before the script exits. + +test "$(trap 'printf trap; echo ped' EXIT; f() { return; }; f)" = trapped || exit 1 diff --git a/tools/regression/bin/sh/builtins/trap11.0 b/tools/regression/bin/sh/builtins/trap11.0 new file mode 100644 index 0000000..cfeea9e --- /dev/null +++ b/tools/regression/bin/sh/builtins/trap11.0 @@ -0,0 +1,8 @@ +# $FreeBSD$ + +# Check that the return statement will not break the USR1 trap, ie. all +# trap commands are executed before the script resumes. + +result=$(${SH} -c 'trap "printf trap; echo ped" USR1; f() { return $(kill -USR1 $$); }; f') +test $? -eq 0 || exit 1 +test "$result" = trapped || exit 1 |