on master help sign in
Ignore PAGER=most by default with a warning to stderr

closes #1063

commit986d0e9777a77b309ffc55de24fcb665adfa3bb7 authorMartin Nordholts <enselic@gmail.com> dateFri 27 Nov 2020, 06:47 (6 years ago) parentf420236
3 files changed+31
CHANGELOG.md+2 src/output.rs+5 tests/integration_tests.rs+24
CHANGELOG.md+2
@@ -5,6 +5,8 @@
55
66## Bugfixes
77
8+- Ignore PAGER=most by default with a warning to stderr, but allow override with BAT_PAGER or --config, see #1063 (@Enselic)
9+
810## Other
911
1012## Syntaxes
src/output.rs+5
@@ -66,6 +66,11 @@ impl OutputType {
6666 return Err(ErrorKind::InvalidPagerValueBat.into());
6767 }
6868
69+ if pager_path.file_stem() == Some(&OsString::from("most")) && source == PagerSource::PagerEnvVar {
70+ eprintln!("WARNING: Ignoring PAGER=\"{}\": Coloring not supported. Override with BAT_PAGER=\"{}\" or --pager \"{}\"", pager, pager, pager);
71+ return Ok(OutputType::stdout());
72+ }
73+
6974 let is_less = pager_path.file_stem() == Some(&OsString::from("less"));
7075
7176 let mut process = if is_less {
tests/integration_tests.rs+24
@@ -415,6 +415,30 @@ fn pager_value_bat() {
415415 .failure();
416416}
417417
418+#[test]
419+fn pager_most() {
420+ bat()
421+ .env("PAGER", "most")
422+ .arg("--paging=always")
423+ .arg("test.txt")
424+ .assert()
425+ .success()
426+ .stderr(predicate::eq("WARNING: Ignoring PAGER=\"most\": Coloring not supported. Override with BAT_PAGER=\"most\" or --pager \"most\"\n").normalize())
427+ .stdout(predicate::eq("hello world\n").normalize());
428+}
429+
430+#[test]
431+fn pager_most_with_arg() {
432+ bat()
433+ .env("PAGER", "most -w")
434+ .arg("--paging=always")
435+ .arg("test.txt")
436+ .assert()
437+ .success()
438+ .stderr(predicate::eq("WARNING: Ignoring PAGER=\"most -w\": Coloring not supported. Override with BAT_PAGER=\"most -w\" or --pager \"most -w\"\n").normalize())
439+ .stdout(predicate::eq("hello world\n").normalize());
440+}
441+
418442#[test]
419443fn alias_pager_disable() {
420444 bat()