Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Call stack issues when running trap handler



I’ve noticed that under certain conditions, shell functions called from
inside an exit trap handler appear to never return. E.g., running the
following code will only yield «a» as output, indicating that callee
«echoa» never returns control to the caller «handler».

#+begin_src shell
trap handler EXIT

handler() {
    echoa
    echo b
}

echoa() {
    echo a
}

exit0() {
    exit
}

main() {
    exit0
}

main

#+end_src

When directly calling «exit0» or «exit» instead of «main», this issue
does not arise.

I was able to reproduce this both in Zsh 5.3.1 as well as today’s HEAD.

Kind regards,
SR



Messages sorted by: Reverse Date, Date, Thread, Author