mirror of
https://github.com/sharkdp/bat.git
synced 2025-01-11 16:18:21 +01:00
When PAGER=most, don't print a warning to stderr, silently use less instead
This commit is contained in:
parent
552545fe5f
commit
22bdc7c20f
@ -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
|
||||
|
||||
|
@ -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"));
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user