Skip to main content

execute

Function execute 

Source
pub fn execute(args: &mut Vec<String>, flags: u32, defpath: i32)
Expand description

Port of static void execute(LinkList args, int flags, int defpath) from Src/exec.c:723. The canonical “child runs the simple external command” path: STTY/ARGV0/BINF_DASH handling, makecline, closem(FDT_XTRACE) + child_unblock, slash-path direct exec, defpath (command -p) search, cmdnamtab + $PATH walk, with commandnotfound-handler fallback and the final exit-code escape (127 not-found / 126 noperm).

§=================== WARNING — DIVERGENCE ==================== (a) cmdnamtab->getnode(cmdnamtab, arg0) (c:824) — HASHED fast-path wired via cmdnamtab_lock(); jumps direct to cn.cmd absolute path before the $PATH scan. Unhashed cursor-walk (c:830-846) still falls to the full $PATH scan; observable behavior matches C when the hash hit is HASHED. (b) commandnotfound(arg0, args) (c:809, 873) calls into the not-yet-ported doshfunc for the command_not_found_handler shell function. Already routes through executor dispatch (see exec.rs:2783). (c) _realexit() (c:810, 874) — bare std::process::exit. (d) SHTTY close on !FD_CLOEXEC (c:781-784) — Rust assumes FD_CLOEXEC platform default (macOS, Linux). (e) path Rust accessor uses paramtab lookup for “PATH”; defpath (command -p) walks DEFAULT_PATH via search_defpath (already ported).