From 025c5c061b8b79609e87e58d74858e9b90fc1458 Mon Sep 17 00:00:00 2001 From: Ethan P Date: Sun, 10 Jan 2021 13:49:06 -0800 Subject: [PATCH] Make less version check accept a path to the less binary --- src/less.rs | 5 +++-- 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 { - let cmd = Command::new("less").arg("--version").output().ok()?; +pub fn retrieve_less_version(less_path: &dyn AsRef) -> Option { + 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"); }