mirror of
https://github.com/sharkdp/bat.git
synced 2025-08-15 10:49:56 +02:00
Fix for Windows: do not run binaries from CWD
This fixes a bug on Windows where `Command::new` would also run executables from the current working directory, possibly resulting in accidental runs of programs called `less`.
This commit is contained in:
@ -4,7 +4,9 @@ use std::ffi::OsStr;
|
||||
use std::process::Command;
|
||||
|
||||
pub fn retrieve_less_version(less_path: &dyn AsRef<OsStr>) -> Option<usize> {
|
||||
let cmd = Command::new(less_path).arg("--version").output().ok()?;
|
||||
let resolved_path = grep_cli::resolve_binary(less_path.as_ref()).ok()?;
|
||||
|
||||
let cmd = Command::new(resolved_path).arg("--version").output().ok()?;
|
||||
parse_less_version(&cmd.stdout)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user