Skip to content

Commit

Permalink
cli: make resolve_binary take COM executables into account
Browse files Browse the repository at this point in the history
When `resolve_binary()` attempts to resolve a path to a program on
Windows while searching for a program in `PATH` without an extension,
`ripgrep` will assume the extension of the file to be `.exe` as it's
the *de facto* standard, which will work most (99.99%) of the time...

...unless the binary is a COM executable (we're on Windows, duh).

Closes #2523
  • Loading branch information
mataha authored and BurntSushi committed Jul 8, 2023
1 parent 545a7dc commit da8ecdd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ TBD
===
Unreleased changes. Release notes have not yet been written.

Feature enhancements:

* Added or improved file type filtering for Fuchsia

Bug fixes:

* [BUG #1891](https://github.com/BurntSushi/ripgrep/issues/1891):
Expand All @@ -10,6 +14,8 @@ Bug fixes:
Disable mmap searching in all non-64-bit environments.
* [BUG #2236](https://github.com/BurntSushi/ripgrep/issues/2236):
Fix gitignore parsing bug where a trailing `\/` resulted in an error.
* [BUG #2523](https://github.com/BurntSushi/ripgrep/issues/2523):
Make executable searching take `.com` into account on Windows.


13.0.0 (2021-06-12)
Expand Down
8 changes: 5 additions & 3 deletions crates/cli/src/decompress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,11 @@ pub fn resolve_binary<P: AsRef<Path>>(
return Ok(abs_prog.to_path_buf());
}
if abs_prog.extension().is_none() {
let abs_prog = abs_prog.with_extension("exe");
if is_exe(&abs_prog) {
return Ok(abs_prog.to_path_buf());
for extension in ["com", "exe"] {
let abs_prog = abs_prog.with_extension(extension);
if is_exe(&abs_prog) {
return Ok(abs_prog.to_path_buf());
}
}
}
}
Expand Down

0 comments on commit da8ecdd

Please sign in to comment.