Skip to content

Commit 291900e

Browse files
authored
Merge pull request #1725 from lzutao/man
Fix man proxy in FreeBSD
2 parents 0865d2e + c24c664 commit 291900e

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/cli/rustup_mode.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,16 +1025,22 @@ fn doc(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
10251025
}
10261026

10271027
fn man(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
1028-
let manpage = m.value_of("command").expect("");
1028+
let command = m.value_of("command").unwrap();
1029+
10291030
let toolchain = explicit_or_dir_toolchain(cfg, m)?;
1030-
let mut man_path = toolchain.path().to_path_buf();
1031-
man_path.push("share");
1032-
man_path.push("man");
1033-
man_path.push("man1");
1034-
man_path.push(manpage.to_owned() + ".1");
1035-
utils::assert_is_file(&man_path)?;
1031+
let mut toolchain = toolchain.path().to_path_buf();
1032+
toolchain.push("share");
1033+
toolchain.push("man");
1034+
utils::assert_is_directory(&toolchain)?;
1035+
1036+
let mut manpaths = std::ffi::OsString::from(toolchain);
1037+
manpaths.push(":"); // prepend to the default MANPATH list
1038+
if let Some(path) = std::env::var_os("MANPATH") {
1039+
manpaths.push(path);
1040+
}
10361041
Command::new("man")
1037-
.arg(man_path)
1042+
.env("MANPATH", manpaths)
1043+
.arg(command)
10381044
.status()
10391045
.expect("failed to open man page");
10401046
Ok(())

0 commit comments

Comments
 (0)