Skip to content

Commit 0aeea2a

Browse files
committed
feat: add support for exec()
1 parent 0a87650 commit 0aeea2a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/lib.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
//! Which is, a lot nicer!
6969
7070
pub use error::*;
71+
#[cfg(unix)]
72+
use std::os::unix::process::CommandExt;
7173
use std::{
7274
ffi::OsStr,
7375
path::Path,
@@ -168,6 +170,7 @@ impl Cmd {
168170
self.status()?;
169171
Ok(())
170172
}
173+
171174
/// Equivalent to [`std::process::Command::spawn`][],
172175
/// but logged and with the error wrapped.
173176
pub fn spawn(&mut self) -> Result<std::process::Child> {
@@ -213,6 +216,19 @@ impl Cmd {
213216
self.status_inner()
214217
}
215218

219+
#[cfg(unix)]
220+
/// Equivalent to [`std::process::Command::exec`][]
221+
/// but logged, with the error wrapped
222+
/// Note that, like the original, this will never return on success
223+
pub fn exec(&mut self) -> Result<ExitStatus> {
224+
self.log_command();
225+
let cause = self.inner.exec();
226+
Err(AxoprocessError::Exec {
227+
summary: self.summary.clone(),
228+
cause,
229+
})
230+
}
231+
216232
/// Actual impl of status, split out to support a polyfill
217233
fn status_inner(&mut self) -> Result<ExitStatus> {
218234
self.log_command();

0 commit comments

Comments
 (0)