diff --git a/CHANGELOG.md b/CHANGELOG.md index af46e011..f17b2da0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ - Make ./tests/syntax-tests/regression_test.sh work on recent versions of macOS, see #1443 (@Enselic) - VimL syntax highlighting fix, see #1450 (@esensar) - Print an 'Invalid syntax theme settings' error message if a custom theme is broken, see #614 (@Enselic) -- Ignore PAGER=most with a warning to stderr, but allow override with BAT_PAGER or --config, see #1063 (@Enselic) +- If `PAGER=most` (but not `BAT_PAGER` or `--pager`), silently use `less` instead since `most` does not support colors, see #1063 (@Enselic) ## Other diff --git a/src/output.rs b/src/output.rs index ce311fe1..ed636cc4 100644 --- a/src/output.rs +++ b/src/output.rs @@ -52,7 +52,6 @@ impl OutputType { use std::path::PathBuf; use std::process::{Command, Stdio}; use crate::pager::*; - use crate::bat_warning; let Pager { pager, source } = get_pager(pager_from_config); @@ -60,16 +59,18 @@ impl OutputType { shell_words::split(&pager).chain_err(|| "Could not parse pager command.")?; match pagerflags.split_first() { - Some((pager_name, args)) => { - let pager_path = PathBuf::from(pager_name); + Some((pager_name, pager_args)) => { + let mut pager_path = PathBuf::from(pager_name); + let mut args = pager_args; + let empty_args = vec![]; if pager_path.file_stem() == Some(&OsString::from("bat")) { return Err(ErrorKind::InvalidPagerValueBat.into()); } if pager_path.file_stem() == Some(&OsString::from("most")) && source == PagerSource::PagerEnvVar { - bat_warning!("Ignoring PAGER=\"{}\": Coloring not supported. Override with BAT_PAGER=\"{}\" or --pager \"{}\"", pager, pager, pager); - return Ok(OutputType::stdout()); + pager_path = PathBuf::from("less"); + args = &empty_args; } let is_less = pager_path.file_stem() == Some(&OsString::from("less")); diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 085e74c8..8fec0140 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -423,8 +423,8 @@ fn pager_most() { .arg("test.txt") .assert() .success() - .stderr(predicate::eq("\x1b[33m[bat warning]\x1b[0m: Ignoring PAGER=\"most\": Coloring not supported. Override with BAT_PAGER=\"most\" or --pager \"most\"\n").normalize()) .stdout(predicate::eq("hello world\n").normalize()); + // TODO: How to ensure less is used? } #[test] @@ -435,8 +435,8 @@ fn pager_most_with_arg() { .arg("test.txt") .assert() .success() - .stderr(predicate::eq("\x1b[33m[bat warning]\x1b[0m: Ignoring PAGER=\"most -w\": Coloring not supported. Override with BAT_PAGER=\"most -w\" or --pager \"most -w\"\n").normalize()) .stdout(predicate::eq("hello world\n").normalize()); + // TODO: How to ensure less is used? } #[test]