Skip to content

Commit

Permalink
issue #383: Handle cases like PAGER=/usr/bin/bat
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Nov 6, 2018
1 parent 148caa1 commit 7cac07d
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,14 @@ impl OutputType {
.chain_err(|| "Could not parse (BAT_)PAGER environment variable.")?;

match pagerflags.split_first() {
Some((initial_pager, mut args)) => {
let pager_name;
if initial_pager == "bat" {
pager_name = "less";
Some((pager_name, mut args)) => {
let mut pager_path = PathBuf::from(pager_name);

if pager_path.file_stem() == Some(&OsString::from("bat")) {
pager_path = PathBuf::from("less");
args = &[];
} else {
pager_name = initial_pager;
}

let pager_path = PathBuf::from(pager_name);
let is_less = pager_path.file_stem() == Some(&OsString::from("less"));

let mut process = if is_less {
Expand Down

0 comments on commit 7cac07d

Please sign in to comment.