Skip to content

Commit f40543e

Browse files
author
Hugo Heuzard
committed
first search for a shell next to cygcheck.exe
1 parent bc11d49 commit f40543e

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/my_std.ml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ let log3 = ref (fun _ -> failwith "My_std.log3 not initialized")
301301

302302
let windows_shell = lazy begin
303303
let rec iter = function
304-
| [] -> [| "bash.exe" ; "--norc" ; "--noprofile" |]
304+
| [] -> raise Not_found
305305
| hd::tl ->
306306
let dash = Filename.concat hd "dash.exe" in
307307
if Sys.file_exists dash then [|dash|] else
@@ -312,9 +312,18 @@ let windows_shell = lazy begin
312312
if Sys.file_exists sh then [|sh|] else [|bash ; "--norc" ; "--noprofile"|]
313313
in
314314
let paths = split_quoted (try Sys.getenv "PATH" with Not_found -> "") ';' in
315-
let res = iter paths in
316-
!log3 (Printf.sprintf "Using shell %s" (Array.to_list res |> String.concat " "));
317-
res
315+
let shell =
316+
try
317+
let path =
318+
List.find (fun path ->
319+
Sys.file_exists (Filename.concat path "cygcheck.exe")) paths
320+
in
321+
iter [path]
322+
with Not_found ->
323+
(try iter paths with Not_found -> failwith "no posix shell found in PATH")
324+
in
325+
!log3 (Printf.sprintf "Using shell %s" (Array.to_list shell |> String.concat " "));
326+
shell
318327
end
319328

320329
let prepare_command_for_windows cmd =

0 commit comments

Comments
 (0)