1
0
mirror of https://github.com/sharkdp/bat synced 2026-07-25 17:21:43 +00:00

warn when pager is missing instead of silently falling back

when a configured pager (via BAT_PAGER, PAGER, or --pager) is not found,
bat now shows a warning message before falling back to stdout. this helps
users understand why their pager isn't running and makes it obvious when
there's a typo or PATH issue.

fixes issue #2904
This commit is contained in:
Ian Maloney
2026-02-19 20:55:18 +00:00
parent fbc05da785
commit d04b960c05
3 changed files with 27 additions and 1 deletions
+11 -1
View File
@@ -105,6 +105,10 @@ impl OutputType {
let resolved_path = match grep_cli::resolve_binary(&pager.bin) {
Ok(path) => path,
Err(_) => {
crate::bat_warning!(
"Pager '{}' not found, outputting to stdout instead",
pager.bin.to_string_lossy()
);
return Ok(OutputType::stdout());
}
};
@@ -174,7 +178,13 @@ impl OutputType {
Ok(p.stdin(Stdio::piped())
.spawn()
.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 {