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

PATCH: EXIT trap runs early when DEBUG and ERR traps are set



Hi there,

Got some bug here to report with the patch included.

Against master (26ba0e39b); also present in 5.9.1 and 5.9.2.

With both a DEBUG and an ERR trap set, the EXIT trap runs, and is
disarmed, when a list finishes instead of when the shell exits:

  zsh -fc 'TRAPDEBUG() { : }; TRAPERR() { : }
  trap "print Exited" EXIT
  f() { return 1 }
  { f; print A }
  print B'

prints A, Exited, B; expected A, B, Exited.  With NO_DEBUG_BEFORE_CMD,
'{ f }' followed by any command shows the same.

execlist() saves the static donetrap in its 'exiting' parameter around
dotrap(SIGDEBUG) and never restores it.  Once an ERR trap has set
donetrap, the DEBUG trap for the last sublist leaves 'exiting' set, and
the "if (exiting && sigtrapped[SIGEXIT])" check at the end of
execlist() fires.  The patch saves donetrap in a local at both DEBUG
sites and adds tests for both option settings.

PS I'm not subscribed; please Cc me.

Cheers,
Simon Fossom

Attachment: 0001-execlist-save-donetrap-in-a-local-not-the-exiting-pa.patch
Description: Binary data



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