Debug

debug_trap_err

Enable ERR trap to call debug_err_handler on any error.

Exit codes

  • 0: Always

debug_err_handler

Handle ERR trap: print a stack trace and exit. Uses the portable caller(1) builtin for the stack trace. Bash users can get richer output (function names, formatted frames) by loading core/stacktrace before enabling this trap — stacktrace() will then be available as an alternative to the caller loop below.

Arguments

  • $1 (int): The exit code from the failing command

Exit codes

  • Propagates the original error exit code

Output on stderr

  • Stack trace and error exit code

debug

Emit a debug trace when debug_mode is true. Uses the no-op colon builtin so output appears only in xtrace (-x) output.

Exit codes

  • 0: Always

debug_step

Like debug(), but pauses for a keypress before continuing.

Exit codes

  • 0: Always

debug_breakpoint

Drop into an interactive debug REPL at the call site. Keys: o=options, p=parameters, a=indexed arrays, A=assoc arrays, x=enable xtrace, X=disable xtrace, q=quit.

Exit codes

  • 0: Always