Skip to main content

getoutput

Function getoutput 

Source
pub fn getoutput(cmd: &str) -> String
Expand description

Free-function wrapper for getoutput() from Src/exec.c:4712. Runs a command-substitution body in the active executor and returns its captured stdout. The C signature is LinkList getoutput(char *cmd, int qt) but every caller in subst.rs joins the list back into a string, so the Rust port collapses the intermediate.

Uses with_executor (panics on missing VM context), not try_with_executor + unwrap_or_default(). C getoutput calls execpline directly — there’s no “no shell” code path. The silent-no-op pattern (return empty string when no executor) would mask catastrophic state corruption as “command produced no output”, which is the failure mode the subst.rs:496 warning block flags.