Skip to content

Commit

Permalink
Avoid endless bat executions with PAGER="bat"
Browse files Browse the repository at this point in the history
From issue sharkdp#383
  • Loading branch information
rodorgas committed Oct 31, 2018
1 parent dda27b2 commit f0325b2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ impl OutputType {
/// Try to launch the pager. Fall back to stdout in case of errors.
fn try_pager(quit_if_one_screen: bool, pager_from_config: Option<&str>) -> Result<Self> {
let pager_from_env = env::var("BAT_PAGER").or_else(|_| env::var("PAGER"));
let pager = pager_from_config

let mut pager = pager_from_config
.map(|p| p.to_string())
.or(pager_from_env.ok())
.unwrap_or(String::from("less"));

if pager == "bat" {
pager = String::from("less");
}

let pagerflags = shell_words::split(&pager)
.chain_err(|| "Could not parse (BAT_)PAGER environment variable.")?;

Expand Down

0 comments on commit f0325b2

Please sign in to comment.