Skip to main content

execcmd_exec

Function execcmd_exec 

Source
pub fn execcmd_exec(
    state: &mut estate,
    eparams: &mut execcmd_params,
    input: i32,
    output: i32,
    how: i32,
    last1: i32,
    close_if_forked: i32,
)
Expand description

Port of execcmd_exec(Estate state, Execcmd_params eparams, int input, int output, int how, int last1, int close_if_forked) from Src/exec.c:2900-4404. Execute a command at the lowest level of the hierarchy.

Line-by-line port of the full 1500-line C body. Sections: c:2904-2916 — locals c:2917-2924 — eparams field unpacking c:2934-2939 — Z_TIMED + doneps4 reset c:2945-2960 — old_lastval + use_cmdoutval + save[]/mfds[] init c:2962-2986 — %job head rewrite + AUTORESUME prefix match c:2988-3011 — Z_ASYNC / pipeline-not-last / sh-emulation fork-immediately c:3013-3283 — precommand-modifier walk (BINF_PREFIX strip) + BINF_COMMAND (-p/-v/-V) + BINF_EXEC (-a/-c/-l) c:3285-3307 — prefork substitutions + magic_assign c:3309-3406 — empty-command branch (redir / nullexec / BINF_COMMAND) c:3409-3466 — main resolution loop (shfunc / builtin / autocd) c:3468-3479 — errflag bail-out c:3480-3492 — text fetch + setunderscore c:3494-3524 — rm * safety prompt c:3526-3591 — type-specific dispatch prep (WC_FUNCDEF / is_shfunc / WC_AUTOFN) c:3593-3632 — external resolution (cmdnamtab, hashcmd, AUTOCD) c:3634-3697 — fork decision c:3700-3955 — redir loop + multio + addfd + xpandredir c:3957-3961 — multio close (mfds[i].ct >= 2 → closemn) c:3963-3995 — nullexec branch c:3996-4327 — main dispatch (entersubsh + execfuncdef / execcurshtable[] / execbuiltin / execshfunc / execute) c:4330-4365 — err: label: forked-child fd cleanup, fixfds c:4366-4403 — done: label: POSIX special-builtin error escalation, shelltime stop, newxtrerr close, AUTOCONTINUE restore

Substrate stubs (declared inside this fn citing home C file):

  • save_params(state, varspc, restorelist, removelist) → Src/exec.c:4409
  • restore_params(restorelist, removelist) → Src/exec.c:4463
  • isreallycom(cn) → Src/exec.c:2670
  • execerr() → Src/exec.c:2700 (label-style; converts to errflag set + goto-equivalent)
  • execautofn_basic(state, do_exec) → Src/exec.c:5050
  • ensurefeature(modname, "b:", ...) → Src/module.c:1654

NOT routed through fusevm. This canonical port targets the tree-walker dispatcher; the fusevm bytecode VM uses execcmd_compile_head + compile_simple instead. No call site yet — the port closes the substrate gap so future wordcode-walker code can use it.