Skip to content

Commit

Permalink
Auto merge of #1040 - brson:nozshcrash, r=brson
Browse files Browse the repository at this point in the history
Don't crash if modifying multiple profile files

Fixes #1034

cc @rmbreak
  • Loading branch information
bors committed Apr 8, 2017
2 parents 369150a + 7e701b1 commit 42a9ac3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/rustup-cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ macro_rules! pre_install_msg_unix {
() => {
pre_install_msg_template!(
"This path will then be added to your `PATH` environment variable by
modifying the profile file located at:
modifying the profile file{plural} located at:
{rcfiles}"
{rcfiles}"
)};
}

Expand Down Expand Up @@ -492,10 +492,13 @@ fn pre_install_msg(no_modify_path: bool) -> Result<String> {
None
}
}).collect::<Vec<_>>();
assert_eq!(rcfiles.len(), 1); // Only modifying .profile
let plural = if rcfiles.len() > 1 { "s" } else { "" };
let rcfiles = rcfiles.into_iter().map(|f| format!(" {}", f)).collect::<Vec<_>>();
let rcfiles = rcfiles.join("\n");
Ok(format!(pre_install_msg_unix!(),
cargo_home_bin = cargo_home_bin.display(),
rcfiles = rcfiles[0]))
plural = plural,
rcfiles = rcfiles))
} else {
Ok(format!(pre_install_msg_win!(),
cargo_home_bin = cargo_home_bin.display()))
Expand Down

0 comments on commit 42a9ac3

Please sign in to comment.