Skip to main content

Module cmd

Module cmd 

Source
Expand description

Shell command execution helper. Shared command execution helper.

Provides run_cmd_result and run_cmd, both returning Result<String, CmdError> so callers can distinguish “command not found” from “command failed with exit code” from “I/O error spawning process”.

§Security Warning

This module uses sh -c to execute commands. NEVER interpolate user input into command strings — only hardcoded, trusted commands should be used. All commands in this codebase are static literals with no user data interpolation.

Violating this rule causes shell injection attacks. Use std::process::Command directly with .arg() for user-provided values.

Enums§

CmdError
Error type for shell command execution failures.

Functions§

run_cmd
Run a shell command and return trimmed stdout.
run_cmd_result
Run a shell command and return trimmed stdout, or a CmdError if the command fails to execute or exits with a non-zero status.