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

Re: BUG: Exit trap is not executed when error occurs in a function



Hi Eric,

I'm not a maintainer, just an occasional contributor, but I think that your original mail was the right way to report the issue. However, for some reason, Gmail classified this email as spam and iirc it was the same for your original email. Maybe that explains the lack of response.

What you report looks very much like a bug to me. Since it's somewhat related to things I have touched in the past, I was planning on having a closer look but until now I was too busy with other things but it's still on my todo list.

Strangely enough, just a few days before your original email, someone else reported a similar issue (workers/55221) where TRAPEXIT fails to execute on interruptions. If/When I finally get time to look into your issue I will also look into this one.

Philippe



On Wed, Nov 11, 2026 at 1:22 AM Eric Postpischil <eric@xxxxxxx> wrote:
I sent email about the issue below several weeks ago and have not seen any acknowledgement or other response. From https://sourceforge.net/p/zsh/bugs/ and https://zsh.sourceforge.io/FAQ/zshfaq06.html, I thought email here is the way to report bugs. If it is just going to vanish into the wind, so be it—I understand zsh is maintained on a volunteer basis. But if I am missing some bug-reporting procedure or I am mistaken about it being a bug, please let me know. (I have also reported it to Apple, FB25342803.)

Here is the issue:

When the ERR_EXIT option (-e) is set and an error occurs in a function, the exit function is not called. Here is a script to demonstrate:

#!/bin/zsh -ef
TRAPEXIT() { echo "This should be printed but is not." }
() { false }

I found this in zsh 5.9 (arm64-apple-darwin25.0).

                                — edp (Eric Postpischil)
                                https://edp.org



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