mirror of
https://github.com/sharkdp/bat.git
synced 2025-09-17 02:32:26 +01: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:
@@ -63,7 +63,14 @@ impl OutputType {
|
||||
return Err(ErrorKind::InvalidPagerValueBat.into());
|
||||
}
|
||||
|
||||
let mut p = Command::new(&pager.bin);
|
||||
let resolved_path = match grep_cli::resolve_binary(&pager.bin) {
|
||||
Ok(path) => path,
|
||||
Err(_) => {
|
||||
return Ok(OutputType::stdout());
|
||||
}
|
||||
};
|
||||
|
||||
let mut p = Command::new(resolved_path);
|
||||
let args = pager.args;
|
||||
|
||||
if pager.kind == PagerKind::Less {
|
||||
|
Reference in New Issue
Block a user