From d0ec139c3202167e5041758344d9bd2f5cfb5945 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Thu, 14 Nov 2024 21:24:00 -0500 Subject: Honor pager path when checking less version (#1903) --- src/utils/bat/less.rs | 11 ++++------- src/utils/bat/output.rs | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/utils/bat/less.rs b/src/utils/bat/less.rs index 4de3504..8943f57 100644 --- a/src/utils/bat/less.rs +++ b/src/utils/bat/less.rs @@ -1,12 +1,9 @@ +use std::path::PathBuf; use std::process::Command; -pub fn retrieve_less_version() -> Option { - if let Ok(less_path) = grep_cli::resolve_binary("less") { - let cmd = Command::new(less_path).arg("--version").output().ok()?; - parse_less_version(&cmd.stdout) - } else { - None - } +pub fn retrieve_less_version(less_path: PathBuf) -> Option { + let cmd = Command::new(less_path).arg("--version").output().ok()?; + parse_less_version(&cmd.stdout) } fn parse_less_version(output: &[u8]) -> Option { diff --git a/src/utils/bat/output.rs b/src/utils/bat/output.rs index a9cb1e4..747abc7 100644 --- a/src/utils/bat/output.rs +++ b/src/utils/bat/output.rs @@ -178,7 +178,7 @@ fn _make_process_from_less_path( config: &PagerCfg, ) -> Option { if let Ok(less_path) = grep_cli::resolve_binary(less_path) { - let mut p = Command::new(less_path); + let mut p = Command::new(less_path.clone()); if args.is_empty() || replace_arguments_to_less { p.args(vec!["--RAW-CONTROL-CHARS"]); @@ -189,7 +189,7 @@ fn _make_process_from_less_path( // // 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(less_path) { None => { p.arg("--no-init"); } -- cgit v1.2.3