Skip to main content

ShellExecutor

Struct ShellExecutor 

Source
pub struct ShellExecutor {
Show 57 fields pub scriptname: Option<String>, pub scriptfilename: Option<String>, pub loop_signal: Option<LoopSignal>, pub subshell_snapshots: Vec<SubshellSnapshot>, pub inline_env_stack: Vec<Vec<(String, Option<String>, Option<String>)>>, pub current_command_glob_failed: Cell<bool>, pub jobs: JobTable, pub fpath: Vec<PathBuf>, pub zwc_cache: HashMap<PathBuf, ZwcFile>, pub history: Option<HistoryEngine>, pub session_histnum: i64, pub traps: HashMap<String, String>, pub completions: HashMap<String, CompSpec>, pub comp_matches: Vec<CompMatch>, pub comp_groups: Vec<CompGroup>, pub comp_state: CompState, pub zstyles: Vec<zstyle_entry>, pub comp_words: Vec<String>, pub comp_current: i32, pub comp_prefix: String, pub comp_suffix: String, pub comp_iprefix: String, pub comp_isuffix: String, pub local_scope_depth: usize, pub pending_underscore: Option<String>, pub in_dq_context: u32, pub in_scalar_assign: u32, pub session_history_ids: Vec<i64>, pub open_fds: HashMap<i32, File>, pub next_fd: i32, pub profiling_enabled: bool, pub compsys_cache: Option<CompsysCache>, pub compinit_pending: Option<(Receiver<CompInitBgResult>, Instant)>, pub plugin_cache: Option<PluginCache>, pub deferred_compdefs: Vec<Vec<String>>, pub returning: Option<i32>, pub breaking: i32, pub continuing: i32, pub zsh_compat: bool, pub bash_compat: bool, pub posix_mode: bool, pub worker_pool: Arc<WorkerPool>, pub intercepts: Vec<Intercept>, pub async_jobs: HashMap<u32, Receiver<(i32, String)>>, pub next_async_id: u32, pub defer_stack: Vec<Vec<String>>, pub redirect_scope_stack: Vec<Vec<(i32, i32)>>, pub redirect_failed: bool, pub pending_stdin: Option<String>, pub functions_compiled: HashMap<String, Chunk>, pub function_source: HashMap<String, String>, pub function_line_base: HashMap<String, i64>, pub function_def_file: HashMap<String, Option<String>>, pub prompt_funcstack: Vec<(String, i64, Option<String>)>, pub tied_scalar_to_array: HashMap<String, (String, String)>, pub tied_array_to_scalar: HashMap<String, (String, String)>, pub buffer_stack: Vec<String>, /* private fields */
}
Expand description

Top-level shell executor state. Port of the file-static globals + Estate chain Src/exec.c uses — execlist() (line 1349) drives every list, with execpline() (line 1668), execpline2() (line 1991), execsimple() (line 1290), and the per-WC_* execfuncs[] table (line 268) feeding off it. The Rust port collapses everything into one ShellExecutor so we don’t need thread-local globals.

Fields§

§scriptname: Option<String>

Mirrors C zsh’s file-static scriptname (Src/init.c). Used by PS4’s %N and the scriptname:line: … prefix on error messages. Inside a function, MUTATES to the function name (Src/exec.c:5903 scriptname = dupstring(name)). Init sets this in -c mode to the binary basename per init.c:479; when sourcing a file via source/bin_dot, it becomes the resolved file path; otherwise it falls back through $0$ZSH_ARGZERO.

§scriptfilename: Option<String>

Mirrors C zsh’s scriptfilename global (Src/init.c). Tracks the FILE BEING READ (vs scriptname which tracks the active function name during a call). Used by PS4’s %x and certain error-message prefixes that want the file location, NOT the function name.

At -c-mode init, scriptname == scriptfilename == “zsh” (Src/init.c:479). When entering a function, ONLY scriptname updates (exec.c:5903); scriptfilename stays at the outer file path, so %x inside a function still shows the file the function was called from.

§loop_signal: Option<LoopSignal>

Set by break/continue keywords when no enclosing loop in the current chunk’s patch lists. Outer-loop builtins (BUILTIN_RUN_SELECT) observe + clear this after each body run.

§subshell_snapshots: Vec<SubshellSnapshot>

Stack of subshell-state snapshots. Each (…) subshell pushes a copy of variables/arrays/assoc_arrays at entry and pops/restores at exit. Without this, (x=inner; …); echo $x shows inner instead of the outer-scope value.

§inline_env_stack: Vec<Vec<(String, Option<String>, Option<String>)>>

Stack of inline-assignment scopes — X=foo Y=bar cmd pushes a frame at the start, the assigns run inside it, and cmd returns into END_INLINE_ENV which restores both shell-vars and process-env to the pre-frame state. Each frame holds (name, prev_var, prev_env) per assigned name. zsh’s equivalent is the parser-level “addvar” list executed under addvars() (Src/exec.c) right before the command exec.

§current_command_glob_failed: Cell<bool>

Set by expand_glob’s no-match arm when nomatch is on (zsh default) — instructs the simple-command dispatcher to skip executing the current command, set last_status=1, and continue to the next command in the script. zsh’s bin_simple uses the errflag global for the same role: error printed, command suppressed, script continues. Without this we were calling process::exit(1) deep inside expand_glob, killing the whole shell on any unmatched glob even with multi-statement input. Cell because the no-match site only has a &self borrow.

§jobs: JobTable§fpath: Vec<PathBuf>§zwc_cache: HashMap<PathBuf, ZwcFile>§history: Option<HistoryEngine>§session_histnum: i64

Session-relative history line counter. Starts at 0; incremented when an interactive command is recorded. Used by %h/%! in prompt expansion (zsh’s “current history line number”), distinct from the persistent disk history total.

§traps: HashMap<String, String>§completions: HashMap<String, CompSpec>§comp_matches: Vec<CompMatch>§comp_groups: Vec<CompGroup>§comp_state: CompState§zstyles: Vec<zstyle_entry>§comp_words: Vec<String>§comp_current: i32§comp_prefix: String§comp_suffix: String§comp_iprefix: String§comp_isuffix: String§local_scope_depth: usize

Current function scope depth for local tracking.

§pending_underscore: Option<String>

Last arg of the currently-running command, deferred into $_ when the next command dispatches. zsh: $_ reflects the LAST command’s last arg, so echo hi; echo $_ prints hi (not the _ arg of echo $_ itself). Promoted in pop_args and host.exec before the command’s args are read.

§in_dq_context: u32

True while expanding inside a double-quoted context. Set by BUILTIN_EXPAND_TEXT mode 1 around expand_string calls. Used by parameter-flag application to suppress array-only flags ((o)/(O)/(n)/(i)/(M)/(u)) — zsh’s behaviour: those flags only fire in array context.

§in_scalar_assign: u32

True (>0) while expanding the RHS of a scalar assignment. Direct port of zsh’s PREFORK_SINGLE bit set by Src/exec.c::addvars line 2546 (prefork(vl, isstr ? (PREFORK_SINGLE|PREFORK_ASSIGN) : PREFORK_ASSIGN, ...)). Subst_port’s paramsubst reads this via ssub and suppresses (f) / (s:STR:) / (0) / (z) split flags per Src/subst.c:1759 + 3902, so y="${(f)x}" preserves x’s original separator (newlines) instead of re-joining with IFS-first-char (space).

§session_history_ids: Vec<i64>

IDs of history entries explicitly added during this session via print -s. fc -l uses this to scope listings to just the script-added entries (matches zsh’s -c semantics where session history is the only thing visible to the script).

§open_fds: HashMap<i32, File>§next_fd: i32§profiling_enabled: bool§compsys_cache: Option<CompsysCache>§compinit_pending: Option<(Receiver<CompInitBgResult>, Instant)>§plugin_cache: Option<PluginCache>§deferred_compdefs: Vec<Vec<String>>§returning: Option<i32>§breaking: i32§continuing: i32§zsh_compat: bool

zsh compatibility mode - use .zcompdump, fpath scanning, etc. Also serves as the --zsh parity-test flag: caches off, daemon off, plugin_cache replay off so every source re-runs the file fresh per Src/builtin.c:6080-6123 bin_dot semantics.

§bash_compat: bool

bash compatibility mode (--bash). Same parity-mode semantics as zsh_compat (caches/daemon/replay off) plus bash-specific behavior tweaks where bash 5.x diverges from zsh — e.g. BASH_VERSION / BASH_REMATCH exposed, [[ =~ ]] populates match indices the bash way, mapfile/readarray as builtins.

§posix_mode: bool

POSIX sh strict mode — no SQLite, no worker pool, no zsh extensions

§worker_pool: Arc<WorkerPool>

Worker thread pool for background tasks (compinit, process subs, etc.)

§intercepts: Vec<Intercept>

AOP intercept table: command/function name → advice chain. Glob patterns supported (e.g. “git ”, “”).

§async_jobs: HashMap<u32, Receiver<(i32, String)>>

Async job handles: id → receiver for (status, stdout)

§next_async_id: u32

Next async job ID

§defer_stack: Vec<Vec<String>>

Defer stack: commands to run on scope exit (LIFO).

§redirect_scope_stack: Vec<Vec<(i32, i32)>>

Per-scope saved-fd stacks for Op::WithRedirectsBegin/End. Each entry is a Vec of (fd, saved_dup_fd) pairs taken from dup(fd) before the redirect was applied; with_redirects_end dup2s them back and closes.

§redirect_failed: bool

Set by host_apply_redirect when a redirect target couldn’t be opened (permission denied, no such directory, etc). The next builtin/command checks this at entry and short-circuits with status 1 instead of running. Mirrors zsh’s “command skip” on redirect failure.

§pending_stdin: Option<String>

Stdin content set by Op::HereDoc(idx) / Op::HereString for the next command/builtin in this VM. Consumed (and cleared) by the next command.

§functions_compiled: HashMap<String, Chunk>

Compiled function bodies — name → fusevm::Chunk. Populated by BUILTIN_REGISTER_FUNCTION (from FunctionDef lowering) and lazily by ZshrsHost::call_function when only an AST exists in self.functions (autoloaded, sourced, etc.). Op::CallFunction dispatches through here.

§function_source: HashMap<String, String>

Canonical source text for functions. Populated by autoload paths (the raw file/cache body), runtime FuncDef compile (the parsed source span), and unfunction removal. Used by introspection (whence, which, typeset -f) instead of reconstructing from a ShellCommand AST. When a function is in functions_compiled but not here, introspection falls back to text::getpermtext(self.functions[name]).

§function_line_base: HashMap<String, i64>

first_body_line - 1 per compiled function — matches inner ZshCompiler::lineno_offset / zsh funcstack->flineno combined with relative $LINENO for Src/prompt.c:909 %I.

§function_def_file: HashMap<String, Option<String>>

scriptfilename when BUILTIN_REGISTER_COMPILED_FN ran — %x inside a function (prompt.c:931-934) reads funcstack->filename.

§prompt_funcstack: Vec<(String, i64, Option<String>)>

Innermost-last stack of active compiled-call frames for prompt %I / %x.

§tied_scalar_to_array: HashMap<String, (String, String)>

Scalar→(array, sep) tie table set up by typeset -T VAR var [SEP]. Used by BUILTIN_SET_VAR to split the assigned scalar on sep and mirror it into array.

§tied_array_to_scalar: HashMap<String, (String, String)>

Array→(scalar, sep) reverse-tie table. Used by BUILTIN_SET_ARRAY to join the array elements with sep and mirror to the scalar side.

§buffer_stack: Vec<String>

ZLE buffer stack — port of bufstack (zsh/Src/builtin.c:4567, LinkList bufstack). print -z (builtin.c:5039-5045) pushes joined args onto it; read -z and getln (builtin.c:6769-6770) pop the top entry as the input source. zsh treats this as a stack shared between the buffer/zle subsystem and the read path.

Implementations§

Source§

impl ShellExecutor

Source

pub fn drain_compinit_bg(&mut self)

Non-blocking drain of background compinit results. Call this before any completion lookup (prompt, tab-complete, etc.). If the background thread hasn’t finished yet, this is a no-op.

Source§

impl ShellExecutor

Source

pub fn host_apply_redirect(&mut self, fd: u8, op_byte: u8, target: &str)

Source

pub fn host_redirect_scope_begin(&mut self, _count: u8)

Push a fresh redirect scope. _count is informational — the actual saved fds are appended by host_apply_redirect into the top scope.

Source

pub fn host_redirect_scope_end(&mut self)

Pop the top redirect scope, restoring saved fds.

Source

pub fn host_set_pending_stdin(&mut self, content: String)

Set up content as stdin (fd 0) for the next command via a real pipe. Used by Op::HereDoc(idx) and Op::HereString.

The pattern: dup2 the read end of a fresh pipe onto fd 0, save the original fd 0 into the active redirect scope so WithRedirectsEnd restores it, and spawn a thread that writes content to the write end and closes it (so the consumer sees EOF after the body). A thread is needed because writing could block on a finite pipe buffer.

Source

pub fn host_exec_external(&mut self, args: &[String]) -> i32

Spawn an external command using zshrs’s full dispatch logic (intercepts, command_hash, redirect handling). Used by ZshrsHost::exec so the bytecode VM’s Op::Exec and Op::CallFunction external fallback get the same semantics as the tree-walker’s execute_external rather than a plain Command::new shortcut. Returns the exit status.

Source§

impl ShellExecutor

Source

pub fn set_scalar(&mut self, name: String, value: String)

Set a scalar parameter via the canonical paramtab (Src/params.c:3350 setsparam). The single store.

Source

pub fn pparams(&self) -> Vec<String>

Read positional parameters from canonical PPARAMS Mutex<Vec<String>> (Src/init.c:pparams). The single store.

Source

pub fn set_pparams(&mut self, params: Vec<String>)

Write positional parameters to canonical PPARAMS.

Source

pub fn param_flags(&self, name: &str) -> i32

Read PM_* type flags from the paramtab Param entry. Used by SET_VAR / += arms (case-fold, integer-add, readonly guard) instead of the legacy exec.var_attrs HashMap. Returns 0 when the name isn’t in paramtab. Mirrors the C source’s direct pm->node.flags & PM_INTEGER checks.

Source

pub fn is_integer_param(&self, name: &str) -> bool

typeset -i name — Param has PM_INTEGER. Reads via param_flags.

Source

pub fn is_float_param(&self, name: &str) -> bool

typeset -F / -E — float.

Source

pub fn is_lowercase_param(&self, name: &str) -> bool

typeset -l — Param has PM_LOWER.

Source

pub fn is_uppercase_param(&self, name: &str) -> bool

typeset -u — Param has PM_UPPER.

Source

pub fn is_readonly_param(&self, name: &str) -> bool

readonly / typeset -r — Param has PM_READONLY.

Source

pub fn last_status(&self) -> i32

Most-recent-command exit status. Reads canonical builtin::LASTVAL AtomicI32 (Src/builtin.c:6443).

Source

pub fn set_last_status(&mut self, status: i32)

Write the most-recent-command exit status. The canonical store is builtin::LASTVAL; this is the single setter. Used everywhere $? / %? / errexit / ZERR trap read.

Source

pub fn set_array(&mut self, name: String, value: Vec<String>)

Set an indexed array parameter via canonical paramtab (setaparam, Src/params.c:3595). The single store.

Source

pub fn set_assoc(&mut self, name: String, value: IndexMap<String, String>)

Set an associative array parameter via canonical sethparam (Src/params.c:3602). The single store.

Source

pub fn scalar(&self, name: &str) -> Option<String>

Read a scalar parameter. Mirrors C getsparam at Src/params.c:3076 — reads through paramtab, falls back to special-var hooks and env.

Source

pub fn array(&self, name: &str) -> Option<Vec<String>>

Read an array parameter from canonical paramtab. Mirrors C getaparam at Src/params.c:3100paramtab->getnode(s) then pm->u.arr.clone(). Returns an owned Vec<String>.

Source

pub fn assoc(&self, name: &str) -> Option<IndexMap<String, String>>

Read an associative array parameter from canonical paramtab_hashed_storage. Mirrors C gethparam at Src/params.c:3115 — returns the typed IndexMap.

Source

pub fn has_scalar(&self, name: &str) -> bool

Test whether a scalar parameter exists in paramtab. Mirrors the C paramtab->getnode(name) != NULL check.

Source

pub fn has_array(&self, name: &str) -> bool

Test whether an array parameter exists in paramtab.

Source

pub fn has_assoc(&self, name: &str) -> bool

Test whether an associative array parameter exists. Reads canonical paramtab_hashed_storage (Src/params.c hashed PM_HASHED slot).

Source

pub fn unset_assoc(&mut self, name: &str)

Unset an associative array parameter from canonical paramtab

  • paramtab_hashed_storage. Direct port of unsetparam_pm for a PM_HASHED Param.
Source

pub fn alias(&self, name: &str) -> Option<String>

Read a regular (non-global) alias value. Reads canonical aliastab (Src/hashtable.c:1186). Filters out aliases that have the ALIAS_GLOBAL flag set so the regular-alias slot is distinct from the global-alias slot, mirroring C’s two separate dispatch paths via aliasflags checks.

Source

pub fn global_alias(&self, name: &str) -> Option<String>

Read a global alias value (alias -g). Reads canonical aliastab and filters to entries with the ALIAS_GLOBAL flag.

Source

pub fn suffix_alias(&self, name: &str) -> Option<String>

Read a suffix alias value (alias -s). Reads canonical sufaliastab (Src/hashtable.c:1187).

Source

pub fn set_alias(&mut self, name: String, value: String)

Set a regular alias. Writes canonical aliastab with ALIAS_GLOBAL bit cleared.

Source

pub fn set_global_alias(&mut self, name: String, value: String)

Set a global alias (alias -g). Writes canonical aliastab with ALIAS_GLOBAL bit set.

Source

pub fn set_suffix_alias(&mut self, name: String, value: String)

Set a suffix alias (alias -s ext=cmd). Writes canonical sufaliastab.

Source

pub fn unset_alias(&mut self, name: &str)

Unset an alias from canonical aliastab (any flag). Mirrors C’s unalias lookup.

Source

pub fn unset_suffix_alias(&mut self, name: &str)

Unset a suffix alias.

Source

pub fn alias_entries(&self) -> Vec<(String, String)>

Snapshot the alias map as a sorted Vec<(name, value)>, only entries WITHOUT the ALIAS_GLOBAL flag (regular aliases).

Source

pub fn global_alias_entries(&self) -> Vec<(String, String)>

Snapshot the global-alias entries (ALIAS_GLOBAL flag set).

Source

pub fn suffix_alias_entries(&self) -> Vec<(String, String)>

Snapshot the suffix-alias entries.

Source

pub fn unset_array(&mut self, name: &str)

Unset an array parameter. Direct port of unsetparam_pm for a PM_ARRAY Param. Mirrors are kept for now while the field transitions.

Source

pub fn unset_scalar(&mut self, name: &str)

Unset a scalar parameter from canonical paramtab. Narrower than unset_var which clears arrays + assocs too. Direct port of Src/params.c:unsetparam_pm for a scalar PM_TYPE.

Source

pub fn new() -> Self

Single-string substitution via the canonical pipeline. Snapshots the executor state into a SubstState, runs singsub from Src/subst.c:514, commits any side-effects (assigns inside ${var:=default}, etc.) back to the executor.

Replaces the bot-invented expand_string method that was deleted in the citation purge (180463e1e7). All call sites that previously did exec.singsub(s) now do exec.singsub(s) and route

Source

pub fn add_fpath(&mut self, path: PathBuf)

Add a directory to fpath

Source

pub fn execute_script_file(&mut self, file_path: &str) -> Result<i32, String>

Tab expansion — direct port of zexpandtabs(const char *s, int len, int width, int startpos, FILE *fout, int all) in zsh/Src/utils.c:5973. Moved to crate::ported::utils::zexpandtabs; re-exported below. Execute a script file with bytecode caching — skips lex+parse+compile on cache hit. Bytecode is stored in rkyv keyed by (path, mtime).

Source

pub fn exec_wordcode(&mut self) -> i32

P9d: wordcode-consumer entry. Direct port of zsh’s execlist from Src/exec.c:1551-1671 — walks the wordcode buffer that P9c’s par_event_wordcode emitted into ECBUF, dispatching on WC_KIND (wc_code) for each entry.

Minimal implementation: walks ECBUF, dispatches WC_END to a no-op return-0 path. The full WC_LIST/WC_SUBLIST/WC_PIPE/WC_CMD/ WC_REDIR/WC_SIMPLE/… dispatch tree (Src/exec.c ~30k lines total) is the multi-week rewrite called out in PORT_PLAN.md. This stub establishes the entry point and proves the consumer can walk a buffer P9c emitted into.

Source

pub fn exec_list_wordcode(&mut self, buf: &[u32], pc: usize) -> (i32, usize)

P9d stub: direct port of execlist(Estate state, int dont_change_job, int exiting) from Src/exec.c:1551-1671. Walks WC_LIST entries, dispatches each sublist payload to exec_pline_wordcode. Real implementation handles fork/wait + signal-trap dispatch. Returns (last_status, pc_after_walk).

Source

pub fn exec_sublist_wordcode(&mut self, buf: &[u32], pc: usize) -> (i32, usize)

P9d stub: direct port of execsublist from Src/exec.c:1672-1810. Walks WC_SUBLIST + pipeline payload.

Source

pub fn exec_pline_wordcode(&mut self, buf: &[u32], pc: usize) -> (i32, usize)

P9d stub: direct port of execpline from Src/exec.c:1812-1980. Walks WC_PIPE chain + cmd payloads.

Source

pub fn exec_cmd_wordcode(&mut self, buf: &[u32], pc: usize) -> (i32, usize)

P9d: direct port of execcmd_exec / execcmd_analyze from Src/exec.c:2700-3700. Reads the cmd header (WC_SIMPLE / WC_SUBSH / WC_FOR / WC_CASE / …) and dispatches accordingly.

Source

pub fn exec_for_wordcode(&mut self, buf: &[u32], pc: usize) -> (i32, usize)

P9d: direct port of execfor(Estate state, int do_exec) from Src/exec.c:1232-1350. Reads WC_FOR header via WC_FOR_TYPE/WC_FOR_SKIP, dispatches on type (PPARAM / LIST / COND), iterates body via recursive exec_list_wordcode calls.

Source

pub fn exec_select_wordcode(&mut self, buf: &[u32], pc: usize) -> (i32, usize)

P9d: execselect shape — same as exec_for but with select REPL prompt at each iteration. Src/exec.c:1352-1490.

Source

pub fn exec_case_wordcode(&mut self, buf: &[u32], pc: usize) -> (i32, usize)

P9d: direct port of execcase(Estate state, int do_exec) from Src/exec.c:1492-1550. Reads WC_CASE_TYPE + WC_CASE_SKIP, walks pattern arms.

Source

pub fn exec_if_wordcode(&mut self, buf: &[u32], pc: usize) -> (i32, usize)

P9d: full port of execif(Estate state, int do_exec) from Src/loop.c:299-340.

C body walks the if/elif/else chain. Each cond is an inner WC_IF header with WC_IF_TYPE distinguishing IF / ELIF / ELSE. Returns lastval = status of the run branch, or 0 if no branch matched.

Source

pub fn exec_while_wordcode(&mut self, buf: &[u32], pc: usize) -> (i32, usize)

P9d: full port of execwhile(Estate state, UNUSED(int do_exec)) from Src/loop.c:432-498.

Loops {exec cond; check status XOR isuntil; exec body; check breaks/contflag/retflag/errflag} until termination.

Source

pub fn exec_repeat_wordcode(&mut self, buf: &[u32], pc: usize) -> (i32, usize)

P9d: full port of execrepeat(Estate state, UNUSED(int do_exec)) from Src/loop.c:499-552.

C body: end = state->pc + WC_REPEAT_SKIP(code); tmp = ecgetstr(state, EC_DUPTOK, &htok); if (htok) { singsub(&tmp); untokenize(tmp); } count = mathevali(tmp); loops++; loop = state->pc; while (count– > 0) { state->pc = loop; execlist(state, 1, 0); if (breaks) { breaks–; if (breaks || !contflag) break; contflag = 0; } if (errflag) { lastval = 1; break; } if (retflag) break; } loops–;

Source

pub fn exec_funcdef_wordcode(&mut self, buf: &[u32], pc: usize) -> (i32, usize)

P9d stub: execfuncdef.

Source

pub fn exec_subsh_wordcode(&mut self, buf: &[u32], pc: usize) -> (i32, usize)

P9d stub: execsubsh for (...) subshell.

Source

pub fn exec_cursh_wordcode(&mut self, buf: &[u32], pc: usize) -> (i32, usize)

P9d stub: execcursh for {...} brace group.

Source

pub fn exec_timed_wordcode(&mut self, buf: &[u32], pc: usize) -> (i32, usize)

P9d stub: exectimed for time pipeline.

Source

pub fn exec_cond_wordcode(&mut self, buf: &[u32], pc: usize) -> (i32, usize)

P9d stub: execcond for [[ ... ]].

Source

pub fn exec_arith_wordcode(&mut self, buf: &[u32], pc: usize) -> (i32, usize)

P9d stub: execarith for (( ... )).

Source

pub fn exec_try_wordcode(&mut self, buf: &[u32], pc: usize) -> (i32, usize)

P9d stub: exectry for { try } always { finally }.

Source

pub fn exec_simple_wordcode(&mut self, buf: &[u32], pc: usize) -> (i32, usize)

P9d: direct port of execsimple(Estate state) from Src/exec.c:3702-4100. Walks WC_SIMPLE header + word slots, decodes the interned strings via ecgetstr, builds argv, invokes the command. Real implementation handles assignments + redirections inline from the same wordcode; this minimal version pulls just words.

Source

pub fn execute_script_zsh_pipeline( &mut self, script: &str, ) -> Result<i32, String>

Execute via the lex+parse free fns + ZshCompiler pipeline. This is the only execution path; execute_script delegates here.

Source

pub fn execute_script(&mut self, script: &str) -> Result<i32, String>

Source

pub fn function_exists(&self, name: &str) -> bool

Whether name is a known function. Checks the compiled-functions table and the autoload-pending registry — autoload foo should make whence foo/type foo/functions foo recognize foo as a function before it’s actually loaded. Doesn’t trigger autoload itself; use maybe_autoload first if you need to load before introspecting.

Source

pub fn function_definition_text(&self, name: &str) -> Option<String>

Canonical source text for a function. Returns from function_source (populated by autoload paths and runtime FuncDef registration via BUILTIN_REGISTER_COMPILED_FN with body_source). Returns None if no canonical source is on file.

Source

pub fn remove_function(&mut self, name: &str) -> bool

Remove a function from both tables (compiled chunk + canonical source). Returns true iff at least one table held it.

Source

pub fn function_names(&self) -> Vec<String>

Sorted list of every known function name (union of compiled + source).

Source

pub fn dispatch_function_call( &mut self, name: &str, args: &[String], ) -> Option<i32>

Dispatch a function by name through the new (compiled) pipeline. Mirrors ZshrsHost::call_function’s resolution order — checks functions_compiled first, triggers autoload if needed, then falls back to the legacy AST recompile path. Returns None if the name isn’t a function (caller falls back to external dispatch).

This is the synchronous-side replacement for the legacy call_function(&ShellCommand, args). It avoids the AST detour when the new pipeline already has a Chunk for the function.

Source

pub fn run_command_substitution(&mut self, cmd_str: &str) -> String

Source§

impl ShellExecutor

Source

pub fn zfork(&mut self, flags: ForkFlags) -> Result<ForkResult>

Fork a new process Port of zfork(struct timespec *ts) from exec.c

Source

pub fn zexecve(&self, cmd: &str, args: &[String]) -> !

Execute a command in the current process (exec family) Port of zexecve(char *pth, char **argv, char **newenvp) from exec.c

Source

pub fn entersubsh(&mut self, flags: SubshellFlags)

Enter a subshell Port of entersubsh(int flags, struct entersubsh_ret *retp) from exec.c

Source§

impl ShellExecutor

Source

pub fn get_special_array_value( &self, array_name: &str, key: &str, ) -> Option<String>

Get value from zsh/parameter special arrays (options, commands, functions, etc.) Returns Some(value) if this is a special array access, None otherwise

Source§

impl ShellExecutor

Source

pub fn run_trap(&mut self, signal: &str)

Execute trap handlers for a signal

Source§

impl ShellExecutor

Source

pub fn expand_glob(&self, pattern: &str) -> Vec<String>

Expand glob pattern to matching files

Source§

impl ShellExecutor

Source

pub fn enter_posix_mode(&mut self)

Source

pub fn enter_ksh_mode(&mut self)

Trait Implementations§

Source§

impl Default for ShellExecutor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,