summaryrefslogtreecommitdiff
path: root/Test
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2016-03-07 09:42:21 +0000
committerPeter Stephenson <pws@zsh.org>2016-03-07 09:42:21 +0000
commit17fb014dc7984902a6697c6412b0cca55300542b (patch)
tree0fcae721ebf4ea22a2258b26712b14b74d71d4e2 /Test
parentbc958ab27591f3bb717efeb95fa541ee14a2405b (diff)
downloadzsh-17fb014dc7984902a6697c6412b0cca55300542b.tar.gz
zsh-17fb014dc7984902a6697c6412b0cca55300542b.zip
38094: Fix POSIX EXIT traps defined in function.
These aren't local, so set the local level to 0; else they can get overridden incorrectly.
Diffstat (limited to 'Test')
-rw-r--r--Test/C03traps.ztst22
1 files changed, 20 insertions, 2 deletions
diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst
index f4466b556..83c05aa08 100644
--- a/Test/C03traps.ztst
+++ b/Test/C03traps.ztst
@@ -429,14 +429,32 @@
fn
echo exiting program
')
-0:POSX EXIT trap can have nested native mode EXIT trap
+0:POSIX EXIT trap can have nested native mode EXIT trap
>entering program
>entering native zsh function
>native zsh function-local exit trap triggered
>exiting program
>POSIX exit trap triggered
- (set -e
+ (cd ..; $ZTST_exe -fc '
+ echo entering program
+ emulate sh -c '\''spt() { trap "echo POSIX exit trap triggered" EXIT; }'\''
+ fn() {
+ trap "echo native zsh function-local exit trap triggered" EXIT
+ echo entering native zsh function
+ }
+ spt
+ fn
+ echo exiting program
+ ')
+0:POSIX EXIT trap not replaced if defined within function
+>entering program
+>entering native zsh function
+>native zsh function-local exit trap triggered
+>exiting program
+>POSIX exit trap triggered
+
+ (set -e
printf "a\nb\n" | while read line
do
[[ $line = a* ]] || continue