Skip to main content

DONETRAP

Static DONETRAP 

Source
pub static DONETRAP: Atomic<i32>
Expand description

Port of static int donetrap; from Src/exec.c:1351. Tracks whether the ZERR trap has already fired for the current sublist. C source resets to 0 at sublist start (c:1455) and sets to 1 after dotrap(SIGZERR) (c:1602). The check if (!this_noerrexit && !donetrap && !this_donetrap) at c:1598 suppresses re-firing within the same sublist AND, crucially, carries the “already fired” state across a function-call return boundary so the outer caller’s post-command check doesn’t fire ZERR a second time for the same logical error. Bug #303 in docs/BUGS.md.

Reset at each top-level statement boundary via BUILTIN_DONETRAP_RESET emitted by compile_list. Set after dotrap(SIGZERR) fires inside BUILTIN_ERREXIT_CHECK.