captureOutput

public func captureOutput(String) -> String

Runs command through the system shell and returns its captured stdout.

Reads from popen(command, "r") 1 KiB at a time until EOF, then trims a single run of trailing ASCII whitespace (space, tab, LF, CR) so callers don't have to chomp the newline themselves. Stderr is not captured — it goes to the parent's stderr. Returns the empty string if popen fails.

Examples

let branch = captureOutput("git rev-parse --abbrev-ref HEAD"); // "main"

Defined in lang/std/os/proc.ks