diff --git a/src/main.rs b/src/main.rs index c8f5c7e..c143a59 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,6 +18,9 @@ mod file_assoc; #[cfg(not(windows))] mod file_assoc {} +#[cfg(unix)] +use std::os::unix::process::CommandExt; + use log::{debug, error, info}; use serde::{Deserialize, Serialize}; use std::ffi::OsString; @@ -478,18 +481,34 @@ fn try_main() -> MainResult { }) }; - let exit_code = if action.execute { - let cmd_name = action.build_kind.exec_command(); - info!("running `cargo {}`", cmd_name); - let run_quietly = !action.cargo_output; - let mut cmd = action.cargo(cmd_name, &args.script_args, run_quietly)?; - - cmd.status().map(|st| st.code().unwrap_or(1))? - } else { - 0 - }; + #[cfg(unix)] + { + if action.execute { + let cmd_name = action.build_kind.exec_command(); + info!("running `cargo {}`", cmd_name); + let run_quietly = !action.cargo_output; + let mut cmd = action.cargo(cmd_name, &args.script_args, run_quietly)?; + + let err = cmd.exec(); + Err(MainError::from(err)) + } else { + Ok(0) + } + } + #[cfg(not(unix))] + { + let exit_code = if action.execute { + let cmd_name = action.build_kind.exec_command(); + info!("running `cargo {}`", cmd_name); + let run_quietly = !action.cargo_output; + let mut cmd = action.cargo(cmd_name, &args.script_args, run_quietly)?; - Ok(exit_code) + cmd.status().map(|st| st.code().unwrap_or(1))? + } else { + 0 + }; + Ok(exit_code) + } } /**