File tree 1 file changed +14
-8
lines changed 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<()> {
1025
1025
}
1026
1026
1027
1027
fn man ( cfg : & Cfg , m : & ArgMatches < ' _ > ) -> Result < ( ) > {
1028
- let manpage = m. value_of ( "command" ) . expect ( "" ) ;
1028
+ let command = m. value_of ( "command" ) . unwrap ( ) ;
1029
+
1029
1030
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
+ }
1036
1041
Command :: new ( "man" )
1037
- . arg ( man_path)
1042
+ . env ( "MANPATH" , manpaths)
1043
+ . arg ( command)
1038
1044
. status ( )
1039
1045
. expect ( "failed to open man page" ) ;
1040
1046
Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments