ralph/runutil/shell.rs
1//! Shell command helpers.
2//!
3//! Responsibilities:
4//! - Build a platform-appropriate shell command wrapper.
5//!
6//! Not handled here:
7//! - Process output handling, streaming, or error classification.
8//!
9//! Invariants/assumptions:
10//! - Unix uses `sh -c`, Windows uses `cmd /C`.
11
12use std::process::Command;
13
14/// Build a shell command for the current platform (sh -c on Unix, cmd /C on Windows).
15pub fn shell_command(command: &str) -> Command {
16 if cfg!(windows) {
17 let mut cmd = Command::new("cmd");
18 cmd.arg("/C").arg(command);
19 cmd
20 } else {
21 let mut cmd = Command::new("sh");
22 cmd.arg("-c").arg(command);
23 cmd
24 }
25}