mirror of
https://github.com/sharkdp/bat.git
synced 2025-01-31 18:21:04 +00:00
Make less version check accept a path to the less binary
This commit is contained in:
parent
573f34d757
commit
025c5c061b
@ -1,9 +1,10 @@
|
|||||||
#![cfg(feature = "paging")]
|
#![cfg(feature = "paging")]
|
||||||
|
|
||||||
|
use std::ffi::OsStr;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
pub fn retrieve_less_version() -> Option<usize> {
|
pub fn retrieve_less_version(less_path: &dyn AsRef<OsStr>) -> Option<usize> {
|
||||||
let cmd = Command::new("less").arg("--version").output().ok()?;
|
let cmd = Command::new(less_path).arg("--version").output().ok()?;
|
||||||
parse_less_version(&cmd.stdout)
|
parse_less_version(&cmd.stdout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ impl OutputType {
|
|||||||
return Err(ErrorKind::InvalidPagerValueBat.into());
|
return Err(ErrorKind::InvalidPagerValueBat.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut p = Command::new(pager.bin);
|
let mut p = Command::new(&pager.bin);
|
||||||
let args = pager.args;
|
let args = pager.args;
|
||||||
|
|
||||||
if pager.kind == PagerKind::Less {
|
if pager.kind == PagerKind::Less {
|
||||||
@ -92,7 +92,7 @@ impl OutputType {
|
|||||||
//
|
//
|
||||||
// For newer versions (530 or 558 on Windows), we omit '--no-init' as it
|
// For newer versions (530 or 558 on Windows), we omit '--no-init' as it
|
||||||
// is not needed anymore.
|
// is not needed anymore.
|
||||||
match retrieve_less_version() {
|
match retrieve_less_version(&pager.bin) {
|
||||||
None => {
|
None => {
|
||||||
p.arg("--no-init");
|
p.arg("--no-init");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user