on master help sign in
issue #383: Handle cases like `PAGER=/usr/bin/bat`
commit7cac07d84559dc6eb02b643f7f640d81a7a4c07e authorsharkdp <davidpeter@web.de> dateTue 6 Nov 2018, 19:53 (8 years ago) parent148caa1
1 file changed+5−7
src/output.rs+5−7
src/output.rs+5−7
@@ -37,16 +37,14 @@ impl OutputType {
3737 .chain_err(|| "Could not parse (BAT_)PAGER environment variable.")?;
3838
3939 match pagerflags.split_first() {
40− Some((initial_pager, mut args)) => {
41− let pager_name;
42− if initial_pager == "bat" {
43− pager_name = "less";
40+ Some((pager_name, mut args)) => {
41+ let mut pager_path = PathBuf::from(pager_name);
42+
43+ if pager_path.file_stem() == Some(&OsString::from("bat")) {
44+ pager_path = PathBuf::from("less");
4445 args = &[];
45− } else {
46− pager_name = initial_pager;
4746 }
4847
49− let pager_path = PathBuf::from(pager_name);
5048 let is_less = pager_path.file_stem() == Some(&OsString::from("less"));
5149
5250 let mut process = if is_less {