summaryrefslogtreecommitdiffhomepage
path: root/src/exec.h
diff options
context:
space:
mode:
authorSean Kurtz <seankurtz75@gmail.com>2026-11-28 00:18:38 -0600
committerSean Kurtz <seankurtz75@gmail.com>2026-11-28 00:18:38 -0600
commit9cdf5f548dc8e1d5c6315b304819bf0fd60f802f (patch)
treed7a67ca6c3aec6f387fc69b6f1931955e6e116e1 /src/exec.h
parent0fc285274b7dacbba311bdbd4b4697b7ebcac09c (diff)
downloadzash-9cdf5f548dc8e1d5c6315b304819bf0fd60f802f.tar.gz
fix(exec): run the ERR trap when the last command is exec'd
`trap "echo ERR" ERR; /bin/false` printed nothing: the shell replaced itself with the failing program and was gone before the trap could run. The same shortcut made `trap ... ; (/bin/false)` silently skip it. trap_after_last() is true when the EXIT or the ERR trap is set, and both the exec shortcut in run_external() and the in-process subshell shortcut in eval_subshell() now use it instead of trap_has_exit(). tests/zash/errtrap-exec.sh covers the external command, a builtin, a subshell and the two traps together; the first and third lines fail without the change. ksh93 prints ERR for all four.
Diffstat (limited to 'src/exec.h')
-rw-r--r--src/exec.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/exec.h b/src/exec.h
index 88b0b95..89df201 100644
--- a/src/exec.h
+++ b/src/exec.h
@@ -215,6 +215,7 @@ void trap_poll(void);
void trap_reset_child(void);
void trap_reset_exec(void);
bool trap_has_exit(void);
+bool trap_after_last(void);
void trap_run_exit(void);
const sigset_t *trap_spawn_defaults(void);
int builtin_trap(int argc, char **argv);