module Shell:Shell scripting in OCaml.sig..end
This module contains basic blocks for shell scripting in OCaml. It tends to be
much safer than just using Unix.system because it handles errors much more
transparently.
WARNING: it's undergoing some serious changes internally, then next public release of
core should have the changes included
module Ansi:sig..end
module Process:sig..end
type'awith_process_flags =?timeout:Core.Std.Time.Span.t option ->
?working_dir:string -> ?verbose:bool -> ?echo:bool -> ?input:string -> 'a
This module contains basic blocks for shell scripting in OCaml. It tends to be
much safer than just using Unix.system because it handles errors much more
transparently.
WARNING: it's undergoing some serious changes internally, then next public release of
core should have the changes included
type'awith_run_flags =(?expect:int list -> 'a) with_process_flags
This module contains basic blocks for shell scripting in OCaml. It tends to be
much safer than just using Unix.system because it handles errors much more
transparently.
WARNING: it's undergoing some serious changes internally, then next public release of
core should have the changes included
type'acmd =string -> string list -> 'a
This module contains basic blocks for shell scripting in OCaml. It tends to be
much safer than just using Unix.system because it handles errors much more
transparently.
WARNING: it's undergoing some serious changes internally, then next public release of
core should have the changes included
val run : unit cmd with_run_flagsval run_lines : string list cmd with_run_flags
In some cases, the newline should not be stripped (e.g., "cat" will not
"add" a newline). If you care, use run_full for the entire buffer.
val run_one : string cmd with_run_flagsval run_full : string cmd with_run_flagsrun_lines.All these function take a format (like printf) and run it through the shell.
Usage example:
sh "cp -- %s %s" (Filename.quote file1) (Filename.quote file2)
In general it is recommended to avoid using those too much and to prefer the
run* family of function instead because it avoids pitfall like escaping
issues and is much more straightforward to think about.
type('a, 'b)sh_cmd =('a, unit, string, 'b) Pervasives.format4 -> 'a
This module contains basic blocks for shell scripting in OCaml. It tends to be
much safer than just using Unix.system because it handles errors much more
transparently.
WARNING: it's undergoing some serious changes internally, then next public release of
core should have the changes included
val sh : ('a, unit) sh_cmd with_run_flagsval sh_lines : ('a, string list) sh_cmd with_run_flagsval sh_one : ('a, string) sh_cmd with_run_flagsval sh_full : ('a, string) sh_cmd with_run_flagsUsage example:
if Shell.test "diff" ["-q";"--";file1;file2] then
Printf.printf "Files %S and %S are the same\n%!" file1 file2;
type'awith_test_flags =(?true_v:int list -> ?false_v:int list -> 'a) with_process_flags
true if the exit code is in true_v.false if the exit code is in false_v and not in true_v.Process.Failure otherwisetrue_v: default value [0]false_v: default_value [1]Shell scripting in OCaml.
This module contains basic blocks for shell scripting in OCaml. It tends to be
much safer than just using Unix.system because it handles errors much more
transparently.
WARNING: it's undergoing some serious changes internally, then next public release of
core should have the changes included
val test : bool cmd with_test_flagsval sh_test : ('a, bool) sh_cmd with_test_flagsval mkdir_p : ?perm:Core.Std.Unix.file_perm -> string -> unitval ls : string -> string listval quote : string -> stringval is_directory : ?unlink:bool -> string -> boolval is_file : ?unlink:bool -> string -> boolval file_kind : string -> Core.Std.Unix.file_kindval file_exists : string -> boolval copy_file : ?overwrite:bool ->
?perm:Core.Std.Unix.file_perm -> src:string -> dst:string -> unitval rm : string -> unitval cp : string -> string -> unitval whoami : ?real:bool -> unit -> stringval home : unit -> stringval get_group_names : unit -> string listval in_group : string -> boolval hostname : unit -> stringval which : string -> string optionval get_editor : unit -> string optionval mkdir_p : ?perm:Core.Std.Unix.file_perm -> string -> unitval ls : string -> string listval quote : string -> stringval (^/) : string -> string -> stringval ssh : user:string -> host:string -> string -> unitssh user host command run command via sshval scp : ?recurse:bool -> user:string -> host:string -> string -> string -> unitscp user host from to copy local file from to toval echo : ('a, Pervasives.out_channel, unit) Pervasives.format -> 'aval warnf : ('a, unit, string, unit) Pervasives.format4 -> 'aval email : string -> string Core.Std.List.container -> string -> string -> unit