mirror of
https://github.com/sharkdp/bat.git
synced 2026-10-30 10:06:12 +00:00
Merge pull request #3588 from IMaloney/fix/warn-missing-pager
warn when pager is missing instead of silently falling back
This commit is contained in:
3 files changed
+28
-1
No files matched your search
@@ -10,6 +10,7 @@
|
|||||||
- Improve native man pages and command help syntax highlighting by stripping overstriking, see #3517 (@akirk)
|
- Improve native man pages and command help syntax highlighting by stripping overstriking, see #3517 (@akirk)
|
||||||
|
|
||||||
## Bugfixes
|
## Bugfixes
|
||||||
|
- Report error when pager is missing instead of silently falling back, see #3588 (@IMaloney)
|
||||||
- Fix `--wrap=never` and `-S` flags being ignored when piping to pager, see #3592 (@IMaloney)
|
- Fix `--wrap=never` and `-S` flags being ignored when piping to pager, see #3592 (@IMaloney)
|
||||||
- Fix crash with BusyBox `less` on Windows, see #3527 (@Anchal-T)
|
- Fix crash with BusyBox `less` on Windows, see #3527 (@Anchal-T)
|
||||||
- Fix `bat cache --help` failing with 'unexpected argument' error, see #3580 and #3560 (@NORMAL-EX)
|
- Fix `bat cache --help` failing with 'unexpected argument' error, see #3580 and #3560 (@NORMAL-EX)
|
||||||
|
|||||||
+11
-1
@@ -105,6 +105,10 @@ impl OutputType {
|
|||||||
let resolved_path = match grep_cli::resolve_binary(&pager.bin) {
|
let resolved_path = match grep_cli::resolve_binary(&pager.bin) {
|
||||||
Ok(path) => path,
|
Ok(path) => path,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
crate::bat_warning!(
|
||||||
|
"Pager '{}' not found, outputting to stdout instead",
|
||||||
|
pager.bin
|
||||||
|
);
|
||||||
return Ok(OutputType::stdout());
|
return Ok(OutputType::stdout());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -174,7 +178,13 @@ impl OutputType {
|
|||||||
Ok(p.stdin(Stdio::piped())
|
Ok(p.stdin(Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
.map(OutputType::Pager)
|
.map(OutputType::Pager)
|
||||||
.unwrap_or_else(|_| OutputType::stdout()))
|
.unwrap_or_else(|_| {
|
||||||
|
crate::bat_warning!(
|
||||||
|
"Pager '{}' not found, outputting to stdout instead",
|
||||||
|
&pager.bin
|
||||||
|
);
|
||||||
|
OutputType::stdout()
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn stdout() -> Self {
|
pub(crate) fn stdout() -> Self {
|
||||||
|
|||||||
@@ -1425,6 +1425,21 @@ fn pager_failed_to_parse() {
|
|||||||
.stderr(predicate::str::contains("Could not parse pager command"));
|
.stderr(predicate::str::contains("Could not parse pager command"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[serial]
|
||||||
|
fn pager_missing_warning() {
|
||||||
|
bat()
|
||||||
|
.env("BAT_PAGER", "nonexistent-pager-xyz-missing")
|
||||||
|
.arg("--paging=always")
|
||||||
|
.arg("test.txt")
|
||||||
|
.assert()
|
||||||
|
.success()
|
||||||
|
.stderr(predicate::str::contains("[bat warning]"))
|
||||||
|
.stderr(predicate::str::contains("not found"))
|
||||||
|
.stderr(predicate::str::contains("nonexistent-pager-xyz-missing"))
|
||||||
|
.stdout(predicate::str::contains("hello world\n"));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[serial]
|
#[serial]
|
||||||
fn env_var_bat_paging() {
|
fn env_var_bat_paging() {
|
||||||
@@ -1442,6 +1457,7 @@ fn env_var_bat_paging() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn basic_set_terminal_title() {
|
fn basic_set_terminal_title() {
|
||||||
bat()
|
bat()
|
||||||
|
.env("BAT_PAGER", "cat")
|
||||||
.arg("--paging=always")
|
.arg("--paging=always")
|
||||||
.arg("--set-terminal-title")
|
.arg("--set-terminal-title")
|
||||||
.arg("test.txt")
|
.arg("test.txt")
|
||||||
|
|||||||
Reference in new issue
Block a user