Skip to content

Commit

Permalink
first search for a shell next to cygcheck.exe
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Heuzard committed Jun 20, 2024
1 parent 5943be1 commit a7afb96
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/my_std.ml
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ let log3 = ref (fun _ -> failwith "My_std.log3 not initialized")

let windows_shell = lazy begin
let rec iter = function
| [] -> [| "bash.exe" ; "--norc" ; "--noprofile" |]
| [] -> raise Not_found
| hd::tl ->
let dash = Filename.concat hd "dash.exe" in
if Sys.file_exists dash then [|dash|] else
Expand All @@ -312,9 +312,18 @@ let windows_shell = lazy begin
if Sys.file_exists sh then [|sh|] else [|bash ; "--norc" ; "--noprofile"|]
in
let paths = split_quoted (try Sys.getenv "PATH" with Not_found -> "") ';' in
let res = iter paths in
!log3 (Printf.sprintf "Using shell %s" (Array.to_list res |> String.concat " "));
res
let shell =
try
let path =
List.find (fun path ->
Sys.file_exists (Filename.concat path "cygcheck.exe")) paths
in
iter [path]
with Not_found ->
(try iter paths with Not_found -> failwith "no posix shell found in PATH")
in
!log3 (Printf.sprintf "Using shell %s" (Array.to_list shell |> String.concat " "));
shell
end

let prepare_command_for_windows cmd =
Expand Down

0 comments on commit a7afb96

Please sign in to comment.