Skip to content

Replace rustup with running command #972

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

Closed
wants to merge 3 commits into from
Closed
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
36 changes: 23 additions & 13 deletions src/rustup/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,24 +135,34 @@ fn telemetry_rustc<S: AsRef<OsStr>>(mut cmd: Command,
fn run_command_for_dir_without_telemetry<S: AsRef<OsStr>>(
mut cmd: Command, arg0: &str, args: &[S]) -> Result<()>
{
cmd.args(&args);
#[cfg(unix)]
fn run(mut command: Command) -> io::Error {
use std::os::unix::process::CommandExt;
let error = command.exec();
error
}

#[cfg(windows)]
fn run(mut command: Command) -> io::Error {
match command.status() {
Ok(status) => {
// Ensure correct exit code is returned
let code = status.code().unwrap_or(1);
process::exit(code);
}
Err(e) => e
}
}

cmd.args(args);

// FIXME rust-lang/rust#32254. It's not clear to me
// when and why this is needed.
cmd.stdin(process::Stdio::inherit());

match cmd.status() {
Ok(status) => {
// Ensure correct exit code is returned
let code = status.code().unwrap_or(1);
process::exit(code);
}
Err(e) => {
Err(e).chain_err(|| rustup_utils::ErrorKind::RunningCommand {
name: OsStr::new(arg0).to_owned(),
})
}
}
Err(run(cmd)).chain_err(|| rustup_utils::ErrorKind::RunningCommand {
name: OsStr::new(arg0).to_owned(),
})
}

#[cfg(unix)]
Expand Down