}
fn external_command() -> Result<(), (String, std::io::Error)> {
let mut cmd = String::new();
let mut args = Vec::new();
for arg in std::env::args().skip(1) {
if cmd.is_empty() {
cmd.push_str("pijul-");
cmd.push_str(&arg)
} else {
args.push(arg)
}
}
if let Err(e) = run_external_command(&cmd, &args) {
Err((cmd, e))
} else {
Ok(())
}
}
#[cfg(unix)]
fn run_external_command(cmd: &str, args: &[String]) -> Result<(), std::io::Error> {
use std::os::unix::process::CommandExt;
Err(std::process::Command::new(cmd).args(args).exec())
}
#[cfg(windows)]
fn run_external_command(cmd: &str, args: &[String]) -> Result<(), std::io::Error> {
let mut spawned = std::process::Command::new(cmd).args(args).spawn()?;
let status = spawned.wait()?;
std::process::exit(status.code().unwrap_or(1))