From 17fb014dc7984902a6697c6412b0cca55300542b Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 7 Mar 2016 09:42:21 +0000 Subject: 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. --- Test/C03traps.ztst | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'Test') 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 -- cgit 1.4.1