mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-08 12:01:21 +02:00
38024: Improve POSIX and native EXIT traps compatibility.
Allow a nested function trap to leave save and restore a POSIX trap. Still fails if the POSIX trap was defined in a function.
This commit is contained in:
parent
3195003cde
commit
c55d855171
3 changed files with 29 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2016-02-25 Peter Stephenson <p.stephenson@samsung.com>
|
||||||
|
|
||||||
|
* 38024: Src/signals.c, Test/C03traps.ztst: improve 37999 to
|
||||||
|
allow nested zsh-mode EXIT traps not to remove a POSIX EXIT
|
||||||
|
trap.
|
||||||
|
|
||||||
2016-02-19 Daniel Shahaf <d.s@daniel.shahaf.name>
|
2016-02-19 Daniel Shahaf <d.s@daniel.shahaf.name>
|
||||||
|
|
||||||
* unposted: Etc/completion-style-guide: Clarify the term "variant".
|
* unposted: Etc/completion-style-guide: Clarify the term "variant".
|
||||||
|
|
|
@ -920,9 +920,14 @@ removetrap(int sig)
|
||||||
* Note that we save the trap here even if there isn't an existing
|
* Note that we save the trap here even if there isn't an existing
|
||||||
* one, to aid in removing this one. However, if there's
|
* one, to aid in removing this one. However, if there's
|
||||||
* already one at the current locallevel we just overwrite it.
|
* already one at the current locallevel we just overwrite it.
|
||||||
|
*
|
||||||
|
* Note we save EXIT traps based on the *current* setting of
|
||||||
|
* POSIXTRAPS --- so if there is POSIX EXIT trap set but
|
||||||
|
* we are in native mode it can be saved, replaced by a function
|
||||||
|
* trap, and then restored.
|
||||||
*/
|
*/
|
||||||
if (!dontsavetrap &&
|
if (!dontsavetrap &&
|
||||||
(sig == SIGEXIT ? !exit_trap_posix : isset(LOCALTRAPS)) &&
|
(sig == SIGEXIT ? !isset(POSIXTRAPS) : isset(LOCALTRAPS)) &&
|
||||||
locallevel &&
|
locallevel &&
|
||||||
(!trapped || locallevel > (sigtrapped[sig] >> ZSIG_SHIFT)))
|
(!trapped || locallevel > (sigtrapped[sig] >> ZSIG_SHIFT)))
|
||||||
dosavetrap(sig, locallevel);
|
dosavetrap(sig, locallevel);
|
||||||
|
|
|
@ -419,6 +419,23 @@
|
||||||
>end of program
|
>end of program
|
||||||
>EXIT TRAP TRIGGERED
|
>EXIT TRAP TRIGGERED
|
||||||
|
|
||||||
|
(cd ..; $ZTST_exe -fc '
|
||||||
|
echo entering program
|
||||||
|
emulate sh -c '\''trap "echo POSIX exit trap triggered" EXIT'\''
|
||||||
|
fn() {
|
||||||
|
trap "echo native zsh function-local exit trap triggered" EXIT
|
||||||
|
echo entering native zsh function
|
||||||
|
}
|
||||||
|
fn
|
||||||
|
echo exiting program
|
||||||
|
')
|
||||||
|
0:POSX 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
|
(set -e
|
||||||
printf "a\nb\n" | while read line
|
printf "a\nb\n" | while read line
|
||||||
do
|
do
|
||||||
|
|
Loading…
Reference in a new issue