Subject: Re: [BUG] Sticky-sh POSIX_TRAPS are function-local
From: Martijn Dekker <[email-masked]>
To: [email-masked]
Cc: Peter Stephenson <[email-masked]>
Date: Thu, 25 Feb 2016 14:52:24 +0100
List-Id: Zsh Workers List <zsh-workers.zsh.org>

Peter Stephenson schreef op 25-02-16 om 12:53:
> I think this makes nested native mode EXIT traps work while preserving
> a global POSIX mode EXIT trap.

It's nearly there. The new test case in C03traps.ztst succeeds.

But if a function defined with sticky emulation sets a POSIX trap, and
that function is called from native zsh, then the old behaviour returns
and a subsequent function-local trap wipes out the global POSIX trap. So
this still kills my POSIX library functions that set a trap.

New test script that does not succeed yet:

#! Src/zsh -f
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

Expected output is identical to that of the C03traps.ztst test case.

Many thanks,

- M.