diff --git a/src/core/opamStd.ml b/src/core/opamStd.ml index ffbf788f9cf..bf44bb4d77a 100644 --- a/src/core/opamStd.ml +++ b/src/core/opamStd.ml @@ -1073,6 +1073,9 @@ module OpamSys = struct else fun x -> x + let chop_exe_suffix name = + Option.default name (Filename.chop_suffix_opt name ~suffix:".exe") + let windows_process_ancestry = Lazy.from_fun OpamStubs.getProcessAncestry type shell_choice = Accept of shell @@ -1085,10 +1088,11 @@ module OpamSys = struct | "pwsh.exe" -> Some (Accept (SH_pwsh Powershell_pwsh)) | "cmd.exe" -> Some (Accept SH_cmd) | "env.exe" -> Some (Accept SH_sh) + | "" -> None | name -> Option.map (fun shell -> Accept shell) - (shell_of_string (Filename.chop_suffix name ".exe")) + (shell_of_string (chop_exe_suffix name ".exe")) in lazy ( let lazy ancestors = windows_process_ancestry in diff --git a/src/core/opamStd.mli b/src/core/opamStd.mli index 5ce996e871e..d87296542bd 100644 --- a/src/core/opamStd.mli +++ b/src/core/opamStd.mli @@ -503,6 +503,9 @@ module Sys : sig (** Append .exe (only if missing) to executable filenames on Windows *) val executable_name : string -> string + (** Remove .exe (if present) from an executable filename on Windows *) + val chop_exe_suffix : string -> string + (** The different families of shells we know about *) type powershell_host = Powershell_pwsh | Powershell type shell = SH_sh | SH_bash | SH_zsh | SH_csh | SH_fish