summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2024-11-14 21:24:00 -0500
committerGitHub <noreply@github.com>2024-11-14 21:24:00 -0500
commitd0ec139c3202167e5041758344d9bd2f5cfb5945 (patch)
treef706ecdb41dff84fa023f126abcf9e18d0b84c57
parent1fb6f99ec498150f552c1c8b5440152c0c2aade7 (diff)
Honor pager path when checking less version (#1903)
-rw-r--r--src/utils/bat/less.rs11
-rw-r--r--src/utils/bat/output.rs4
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<usize> {
- 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<usize> {
+ let cmd = Command::new(less_path).arg("--version").output().ok()?;
+ parse_less_version(&cmd.stdout)
}
fn parse_less_version(output: &[u8]) -> Option<usize> {
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<Command> {
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");
}