diff options
| author | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-28 14:34:40 -0600 |
|---|---|---|
| committer | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-28 14:34:40 -0600 |
| commit | 78d73092a29cca7e3ce4ef6b5e2c6cd244f40202 (patch) | |
| tree | 11e54f24ebb2d3f528ec31ac467fa864fe92595b /src/exec.h | |
| parent | 93bbcf2f9a75bb5090d96ec9908594e15aa5908b (diff) | |
| parent | 95d31d2d7d5fd7de81d6d5e2caedcdc369ca0fcf (diff) | |
| download | zash-78d73092a29cca7e3ce4ef6b5e2c6cd244f40202.tar.gz | |
Merge main into perf/cd-inproc: one in-process `( cd dir )`, not two
main gained an in-process `( cd dir )` of its own with the 2026-11-28
review merge (the uncommitted working tree the review was written
against, committed as cb1688f), so this branch and main both replaced
the fork for the same command, in two places.
That copy has a defect this branch guards against: with
readonly PWD; ( cd / ); echo after
the readonly assignment raises out of the saved-cwd block and kills the
whole shell - no `after` - where dash and bash both print it (dash rc=2,
bash rc=1). `subshell_in_process()` here refuses to run the `cd`
in-process unless PWD and OLDPWD are plain, and `builtin_cd_isolated()`
holds its own exception handler, so the fork still happens in that case.
Resolution: keep this branch's implementation and drop main's ad-hoc
branch in eval_subshell() together with the curdir_invalidate() helper
added for it, which had no other caller. The tests main brought with it
(tests/zash/subshell-cd.sh, tests/proc/subshell-pure.sh) still pass.
Verified on Linux (7.3.4-300.fc45.x86_64, 2026-11-28): make check 127
passed / 1 skipped / the known linux/i-dscomplete failure, make asan and
make valgrind the same, make mvs-asan 127 passed, make zos-lint clean,
the readonly-PWD case now matches dash. Not re-run on cbt.
Diffstat (limited to 'src/exec.h')
| -rw-r--r-- | src/exec.h | 25 |
1 files changed, 9 insertions, 16 deletions
@@ -1,6 +1,7 @@ /** * @file exec.h * @brief Command evaluation, redirection, jobs, traps and builtins. + * @note The unwind snapshot and the exception handler live in shell.h. */ #ifndef ZASH_EXEC_H #define ZASH_EXEC_H @@ -9,7 +10,6 @@ #include "ast.h" #include "sys.h" -#include "var.h" /* ---- evaluation (exec.c) --------------------------------------------- */ @@ -53,6 +53,7 @@ int run_input(unsigned flags); char *cmdsub_run(node *n, size_t *len); void exec_init(void); [[noreturn]] void shell_exec(char **argv, char **envp); +int shell_exec_try(char **argv, char **envp); /* ---- command table --------------------------------------------------- */ @@ -197,22 +198,10 @@ int builtin_bg(int argc, char **argv); char *node_text(const node *n); -/* ---- unwinding ------------------------------------------------------- */ - -/* Defined in parser.h. */ -typedef struct input_src input_src; - -/** - * @brief State that an exception handler must put back before continuing. +/* + * Unwinding: the unwind snapshot and exc_catch() live in shell.h, and the + * exception itself is raised by exc_raise() in util.c. */ -typedef struct unwind { - varscope *scope; - redirsave *redir; - input_src *input; -} unwind; - -void unwind_save(unwind *u); -void unwind_restore(const unwind *u); /* ---- traps (trap.c) -------------------------------------------------- */ @@ -225,7 +214,10 @@ void trap_run_err(void); void trap_init(void); void trap_poll(void); void trap_reset_child(void); +void trap_reset_exec(void); bool trap_has_exit(void); +void trap_sig_default(int sig); +bool trap_after_last(void); void trap_run_exit(void); const sigset_t *trap_spawn_defaults(void); int builtin_trap(int argc, char **argv); @@ -240,6 +232,7 @@ int eval_cond(const cond *c); int builtin_printf(int argc, char **argv); int builtin_command(int argc, char **argv); int builtin_exec(int argc, char **argv); +int builtin_read_reply(void); int builtin_print(int argc, char **argv); int builtin_whence(int argc, char **argv); int builtin_setvar(int argc, char **argv); |
