Skip to main content

getoutputfile

Function getoutputfile 

Source
pub fn getoutputfile(cmd: &str, eptr: Option<&mut usize>) -> Option<String>
Expand description

Port of char *getoutputfile(char *cmd, char **eptr) from Src/exec.c:4910=(cmd) process substitution.

Substitutes the cmd’s stdout into a temp file, returns the filename. Optimised path: =(<<<heredoc-str) writes the heredoc body directly without a fork.

(a) addfilelist(nam, 0) (c:4960) wired via JOBTAB[thisjob] so the temp file gets cleaned at job exit. (b) waitforpid Rust takes 1 arg pid, C takes (pid, full). Behavior matches the full=0 case anyway. (c) entersubsh is ported at exec.rs:3934 — wire it here when re-routing the fork path away from setsid-only fallback. (d) execode is now ported (exec.rs:6047) — the body still re-feeds through fusevm for cache coherence with execstring. (e) _realexit flushes stdio + jobs + history. We use bare std::process::exit(0) for now. (f) TMPSUFFIX link()-rename block (c:4951-4958) deferred; rare setopt suffix_alias interaction with =(…).