From 80722196683c3b1eac6a2a751063687f2c6187bf Mon Sep 17 00:00:00 2001 From: mataha Date: Tue, 30 May 2023 02:08:06 +0200 Subject: [PATCH] cli: make `resolve_binary()` take COM executables into account 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). (It feels weird being the first person to run into this.) --- crates/cli/src/decompress.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/cli/src/decompress.rs b/crates/cli/src/decompress.rs index 765087097..f2f2a6747 100644 --- a/crates/cli/src/decompress.rs +++ b/crates/cli/src/decompress.rs @@ -455,9 +455,11 @@ pub fn resolve_binary>( 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()); + } } } }