Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use exec() on unix #52

Merged
merged 1 commit into from
May 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 30 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -478,18 +481,34 @@ fn try_main() -> MainResult<i32> {
})
};

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)
}
}

/**
Expand Down