Skip to main content

run_cmd

Function run_cmd 

Source
pub fn run_cmd(cmd: &str) -> Result<String, CmdError>
Expand description

Run a shell command and return trimmed stdout.

§Input

cmd — A shell command string (must be a hardcoded literal — see module docs).

§Output

Ok(String) — Trimmed stdout when the command succeeds (exit code 0).

§Errors

Returns CmdError if the command fails to execute or exits with a non-zero status. Callers should handle the error (log, fallback, or propagate).

§Safety

CRITICAL: Only use with hardcoded, trusted command strings. Never interpolate user input, file paths, or any external data into cmd.