File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -1025,16 +1025,22 @@ fn doc(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
10251025}
10261026
10271027fn 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 ( ( ) )
You can’t perform that action at this time.
0 commit comments