gravel_provider_exec/
linux.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use anyhow::{anyhow, Result};
use std::process::{Command, Stdio};

const SHELL: &str = "sh";

/// Passes the given string to a new bash process.
pub fn run_command(cmd: &str) -> Result<()> {
	log::debug!("running command in {SHELL} '{cmd}'");

	Command::new(SHELL)
		.arg("-c")
		.arg(cmd)
		// explicitly prevent stream inheritance
		.stdin(Stdio::null())
		.stdout(Stdio::null())
		.stderr(Stdio::null())
		.spawn()
		.map(drop)
		.map_err(|e| anyhow!("unable to invoke {SHELL}: {e}"))
}