Skip to content

Commit 9f92a6d

Browse files
authored
Merge pull request #1040 from brson/nozshcrash
Don't crash if modifying multiple profile files
2 parents 4cdbe1b + 7e701b1 commit 9f92a6d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/rustup-cli/self_update.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ macro_rules! pre_install_msg_unix {
8686
() => {
8787
pre_install_msg_template!(
8888
"This path will then be added to your `PATH` environment variable by
89-
modifying the profile file located at:
89+
modifying the profile file{plural} located at:
9090
91-
{rcfiles}"
91+
{rcfiles}"
9292
)};
9393
}
9494

@@ -492,10 +492,13 @@ fn pre_install_msg(no_modify_path: bool) -> Result<String> {
492492
None
493493
}
494494
}).collect::<Vec<_>>();
495-
assert_eq!(rcfiles.len(), 1); // Only modifying .profile
495+
let plural = if rcfiles.len() > 1 { "s" } else { "" };
496+
let rcfiles = rcfiles.into_iter().map(|f| format!(" {}", f)).collect::<Vec<_>>();
497+
let rcfiles = rcfiles.join("\n");
496498
Ok(format!(pre_install_msg_unix!(),
497499
cargo_home_bin = cargo_home_bin.display(),
498-
rcfiles = rcfiles[0]))
500+
plural = plural,
501+
rcfiles = rcfiles))
499502
} else {
500503
Ok(format!(pre_install_msg_win!(),
501504
cargo_home_bin = cargo_home_bin.display()))

0 commit comments

Comments
 (0)