/** * Trap Execution * * Executes registered trap handlers for shell signals/events. * Trap handlers execute in the current shell context (not a subshell). * * Supported signals: * - EXIT: Fires when script finishes (normal or via exit) * - ERR: Fires when a command fails (exitCode !== 0) outside conditions * - DEBUG: Fires before each simple command * - RETURN: Fires after a function or sourced script returns */ import type { ExecResult } from "../types.js"; import type { InterpreterContext } from "./types.js"; /** * Execute the ERR trap if conditions are met. * ERR trap fires when a command fails (exitCode !== 0) and: * - Not inside a condition (if/while/until/&&/||) * - Not in a negated pipeline * - Not already handling an ERR trap (prevent recursion) * * @param ctx - The interpreter context * @param inCondition - Whether we are in a condition context * @param pipelineNegated - Whether the pipeline was negated (! cmd) * @returns The trap execution result, or null if trap was not fired */ export declare function executeErrTrap(ctx: InterpreterContext, inCondition: boolean, pipelineNegated: boolean): Promise; /** * Execute the EXIT trap. * Fires when the script finishes (normal completion, exit, or error). * Idempotent: only fires once per context (prevents re-entry when the trap * handler itself causes executeScript to complete). * * @param ctx - The interpreter context * @returns The trap execution result, or null if no handler registered */ export declare function executeExitTrap(ctx: InterpreterContext): Promise; /** * Execute the RETURN trap. * Fires after a function body completes (both success and failure). * * @param ctx - The interpreter context * @returns The trap execution result, or null if no handler registered */ export declare function executeReturnTrap(ctx: InterpreterContext): Promise;