parent
37b1125f03
commit
8e64aa0990
|
@ -307,18 +307,14 @@ module Mini_shexp = struct
|
||||||
Printf.fprintf oc "# 1 %S\n" (Path.to_string fn);
|
Printf.fprintf oc "# 1 %S\n" (Path.to_string fn);
|
||||||
copy_channels ic oc));
|
copy_channels ic oc));
|
||||||
return ()
|
return ()
|
||||||
| System cmd -> begin
|
| System cmd ->
|
||||||
let path, arg, err =
|
let path, arg =
|
||||||
Utils.system_shell ~needed_to:"interpret (system ...) actions"
|
Utils.system_shell_exn ~needed_to:"interpret (system ...) actions"
|
||||||
in
|
in
|
||||||
match err with
|
run ~dir ~env ~env_extra ~stdout_to ~stderr_to path [arg; cmd]
|
||||||
| Some err -> err.fail ()
|
|
||||||
| None ->
|
|
||||||
run ~dir ~env ~env_extra ~stdout_to ~stderr_to path [arg; cmd]
|
|
||||||
end
|
|
||||||
| Bash cmd ->
|
| Bash cmd ->
|
||||||
run ~dir ~env ~env_extra ~stdout_to ~stderr_to
|
run ~dir ~env ~env_extra ~stdout_to ~stderr_to
|
||||||
(Path.absolute "/bin/bash")
|
(Utils.bash_exn ~needed_to:"interpret (bash ...) actions")
|
||||||
["-e"; "-u"; "-o"; "pipefail"; "-c"; cmd]
|
["-e"; "-u"; "-o"; "pipefail"; "-c"; cmd]
|
||||||
| Update_file (fn, s) ->
|
| Update_file (fn, s) ->
|
||||||
let fn = Path.to_string fn in
|
let fn = Path.to_string fn in
|
||||||
|
|
22
src/utils.ml
22
src/utils.ml
|
@ -1,6 +1,6 @@
|
||||||
open Import
|
open Import
|
||||||
|
|
||||||
let system_shell =
|
let system_shell_exn =
|
||||||
let cmd, arg, os =
|
let cmd, arg, os =
|
||||||
if Sys.win32 then
|
if Sys.win32 then
|
||||||
("cmd", "/c", "on Windows")
|
("cmd", "/c", "on Windows")
|
||||||
|
@ -10,14 +10,20 @@ let system_shell =
|
||||||
let bin = lazy (Bin.which cmd) in
|
let bin = lazy (Bin.which cmd) in
|
||||||
fun ~needed_to ->
|
fun ~needed_to ->
|
||||||
match Lazy.force bin with
|
match Lazy.force bin with
|
||||||
| Some path -> (path, arg, None)
|
| Some path -> (path, arg)
|
||||||
| None ->
|
| None ->
|
||||||
(Path.absolute ("/" ^ cmd),
|
die "I need %s to %s but I couldn't find it :(\n\
|
||||||
arg,
|
Who doesn't have %s%s?!"
|
||||||
Some { fail = fun () ->
|
cmd needed_to cmd os
|
||||||
die "I need %s to %s but I couldn't find it :(\n\
|
|
||||||
Who doesn't have %s%s?!"
|
let bash_exn =
|
||||||
cmd needed_to cmd os })
|
let bin = lazy (Bin.which "bash") in
|
||||||
|
fun ~needed_to ->
|
||||||
|
match Lazy.force bin with
|
||||||
|
| Some path -> path
|
||||||
|
| None ->
|
||||||
|
die "I need bash to %s but I couldn't find it :("
|
||||||
|
needed_to
|
||||||
|
|
||||||
let signal_name =
|
let signal_name =
|
||||||
let table =
|
let table =
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
(** Utilities that can't go in [Import] *)
|
(** Utilities that can't go in [Import] *)
|
||||||
|
|
||||||
open Import
|
open! Import
|
||||||
|
|
||||||
(** Return the absolute path to the shell, the argument to pass it (-c or /c) and a
|
(** Return the absolute path to the shell and the argument to pass it (-c or /c). Raise in
|
||||||
failure in case the shell can't be found. *)
|
case in cannot be found. *)
|
||||||
val system_shell : needed_to:string -> Path.t * string * fail option
|
val system_shell_exn : needed_to:string -> Path.t * string
|
||||||
|
|
||||||
|
(** Same as [system_shell_exn] but for bash *)
|
||||||
|
val bash_exn : needed_to:string -> Path.t
|
||||||
|
|
||||||
(** Convert a signal number to a name: INT, TERM, ... *)
|
(** Convert a signal number to a name: INT, TERM, ... *)
|
||||||
val signal_name : int -> string
|
val signal_name : int -> string
|
||||||
|
|
Loading…
Reference in New Issue