diff --git a/src/lib.rs b/src/lib.rs index e2bdb1b..405c0f0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -70,6 +70,7 @@ pub use error::*; use std::{ ffi::OsStr, + os::unix::process::CommandExt, path::Path, process::{Command, CommandArgs, CommandEnvs, ExitStatus, Stdio}, }; @@ -168,6 +169,7 @@ impl Cmd { self.status()?; Ok(()) } + /// Equivalent to [`std::process::Command::spawn`][], /// but logged and with the error wrapped. pub fn spawn(&mut self) -> Result { @@ -213,6 +215,18 @@ impl Cmd { self.status_inner() } + /// Equivalent to [`std::process::Command::exec`][] + /// but logged, with the error wrapped + /// Note that, like the original, this will never return on success + pub fn exec(&mut self) -> Result { + self.log_command(); + let cause = self.inner.exec(); + Err(AxoprocessError::Exec { + summary: self.summary.clone(), + cause, + }) + } + /// Actual impl of status, split out to support a polyfill fn status_inner(&mut self) -> Result { self.log_command();