mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-12-01 04:10:57 +01:00
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.
This commit is contained in:
parent
bc958ab275
commit
17fb014dc7
3 changed files with 32 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue