diff options
author | Ethan P <eth-p+git@hidden.email> | 2021-01-10 13:49:06 -0800 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2021-02-16 09:11:27 +0100 |
commit | 025c5c061b8b79609e87e58d74858e9b90fc1458 (patch) | |
tree | e59639de5adb1319bfb77c92178bf34f81b96c44 | |
parent | 573f34d757434a5580abd45f5a059c908552d0b3 (diff) |
Make less version check accept a path to the less binary
-rw-r--r-- | src/less.rs | 5 | ||||
-rw-r--r-- | src/output.rs | 4 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/less.rs b/src/less.rs index aaab849f..34b57549 100644 --- a/src/less.rs +++ b/src/less.rs @@ -1,9 +1,10 @@ #![cfg(feature = "paging")] +use std::ffi::OsStr; use std::process::Command; -pub fn retrieve_less_version() -> Option<usize> { - let cmd = Command::new("less").arg("--version").output().ok()?; +pub fn retrieve_less_version(less_path: &dyn AsRef<OsStr>) -> Option<usize> { + let cmd = Command::new(less_path).arg("--version").output().ok()?; parse_less_version(&cmd.stdout) } diff --git a/src/output.rs b/src/output.rs index c79535c3..4aff7686 100644 --- a/src/output.rs +++ b/src/output.rs @@ -63,7 +63,7 @@ impl OutputType { return Err(ErrorKind::InvalidPagerValueBat.into()); } - let mut p = Command::new(pager.bin); + let mut p = Command::new(&pager.bin); let args = pager.args; 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 // is not needed anymore. - match retrieve_less_version() { + match retrieve_less_version(&pager.bin) { None => { p.arg("--no-init"); } |