module Shell:This module provides type definitions, base functions, and combinators allowing to encode shell scripts.sig..end
type ([< `Input | `No_input ], [< `No_output | `Output ], [< `Error | `No_error ]) command
type configuration = {
|
pipe : |
(* | The notation used for shell pipes. | *) |
|
redirect_output : |
(* | The notation used to redirect ouput. | *) |
|
redirect_append_output : |
(* | The notation used to redirect ouput in append mode. | *) |
|
redirect_error : |
(* | The notation used to redirect error. | *) |
|
redirect_append_error : |
(* | The notation used to redirect error in append mode. | *) |
val bash : configurationval set_configuration : configuration -> unitset_configuration c changes the configuration to c.
The default configuration is bash.
val read_lines : string -> string listread_lines file returns the lines from file file.
Raises an exception if an i/o error occurs.val write_lines : string list -> string -> unitwrite_lines l file writes the strings from l to file file,
a '\n' character being written after each string.
Raises an exception if an i/o error occurs.val command : string ->
([< `Input | `No_input ], [< `No_output | `Output ], [< `Error | `No_error ])
commandcommand s lifts s to a command. The user should carefully set the
parameter types of the command type. Should be used only to provide
base commands not defined in this module.val coerce : ([< `Input | `No_input ], [< `No_output | `Output ], [< `Error | `No_error ])
command ->
([< `Input | `No_input ], [< `No_output | `Output ], [< `Error | `No_error ])
commandcoerce c allows one to change the parameter types of the command type.val ignore : ([< `Input | `No_input ] as 'a, [< `No_output | `Output ],
[< `Error | `No_error ])
command -> ('a, [ `No_output ], [ `No_error ]) commandcoerce that ignores both outputs.val run : ([< `Input | `No_input ], [< `No_output | `Output ], [< `Error | `No_error ])
command -> intrun c runs the command c, returning its exit code.val run_list : ([< `Input | `No_input ], [< `No_output | `Output ], [< `Error | `No_error ])
command list -> intval file_exists : string -> boolSys.file_exists.val is_directory : string -> boolSys.is_directory.val getenv : string -> stringSys.getenv.val files : string -> string listSys.readdir except that a list is returned.val files_with_filter : (string -> bool) -> string -> string listfiles except that the returned list is filtered by
the passed function.val files_with_suffix : string -> string -> string listfiles_with_suffix s d equivalent to files d except that only
the files with the suffix s are returned.val current_dir_name : stringFilename.current_dir_name.val parent_dir_name : stringFilename.parent_dir_name.val is_relative : string -> boolFilename.is_relative.val is_implicit : string -> boolFilename.is_implicit.val check_suffix : string -> string -> boolFilename.check_suffix.val chop_suffix : string -> string -> stringFilename.chop_suffix.val chop_extension : string -> stringFilename.chop_extension.val basename : string -> stringFilename.basename.val dirname : string -> stringFilename.dirname.val concatname : string -> string -> stringFilename.concatname.val temp_file : ?temp_dir:string -> string -> string -> stringFilename.temp_file.val quote : string -> stringFilename.quote.val pwd : unit -> stringval cd : string -> unitSys_error if the directory does not exist.val pushd : string -> unitSys_error if the directory does not exist.val popd : unit -> stringStack.Empty if the directory stack is empty.
Raises Sys_error if the directory does not exist.val exit : int -> ([ `No_input ], [ `No_output ], [ `No_error ]) commandexit n builds a command returning the exit code n.val pwdir : unit -> ([ `No_input ], [ `Output ], [ `No_error ]) commandpwd, as a command.val chdir : string -> ([ `No_input ], [ `No_output ], [ `Error ]) commandcd, as a command.val mkdir : ?options:string list ->
string -> ([ `No_input ], [ `No_output ], [ `Error ]) commandmkdir ~options:options path builds a command creating the directory path,
passing options to the mkdir executable. options defaults to [].val rmdir : ?options:string list ->
string -> ([ `No_input ], [ `No_output ], [ `Error ]) commandrmdir ~options:options path builds a command deleting the directory path,
passing options to the rmdir executable. options defaults to [].val ls : ?options:string list ->
string list -> ([ `No_input ], [ `Output ], [ `Error ]) commandls ~options:options l builds a command listing elements from l,
passing options to the ls executable. options defaults to [].val cp : ?options:string list ->
string list ->
string -> ([ `No_input ], [ `No_output ], [ `Error ]) commandcp ~options:options l d builds a command copying elements from l to d,
passing options to the cp executable. options defaults to [].val rm : ?options:string list ->
string list -> ([ `No_input ], [ `No_output ], [ `Error ]) commandrm ~options:options l builds a command deleting elements from l,
passing options to the rm executable. options defaults to [].val mv : ?options:string list ->
string list ->
string -> ([ `No_input ], [ `No_output ], [ `Error ]) commandmv ~options:options l d builds a command moving elements from l to d,
passing options to the mv executable. options defaults to [].val touch : ?options:string list ->
string list -> ([ `No_input ], [ `No_output ], [ `Error ]) commandtouch ~options:options l builds a command touching elements from l,
passing options to the touch executable. options defaults to [].val cat : ?options:string list ->
string list -> ([ `No_input ], [ `Output ], [ `Error ]) commandcat ~options:options l builds a command displaying elements from l,
passing options to the cat executable. options defaults to [].val echo : ?options:string list ->
string -> ([ `No_input ], [ `Output ], [ `Error ]) commandecho ~options:options x builds a command printing x,
passing options to the echo executable. options defaults to [].val diff : ?options:string list ->
string -> string -> ([ `No_input ], [ `Output ], [ `Error ]) commanddiff ~options:options x y builds a command computing the difference between x and y,
passing options to the diff executable. options defaults to [].val grep : ?options:string list ->
string -> ([ `Input ], [ `Output ], [ `Error ]) commandgrep ~options:options x builds a command filtering the input with the expression x,
passing options to the grep executable. options defaults to [].val grep_files : ?options:string list ->
string ->
string list -> ([ `No_input ], [ `Output ], [ `Error ]) commandgrep_files ~options:options x l builds a command filtering the files from l
with the expression x, passing options to the grep executable.
options defaults to [].val sed : ?options:string list ->
string -> ([ `Input ], [ `Output ], [ `Error ]) commandsed ~options:options x builds a command applying the expression x to input,
passing options to the sed executable. options defaults to [].val sort : ?options:string list ->
string list -> ([ `Input ], [ `Output ], [ `Error ]) commandsed ~options:options l builds a command sorting the data it receives,
passing options to the sort executable. options defaults to [].val cut : ?options:string list ->
string list -> ([ `Input ], [ `Output ], [ `Error ]) commandcut ~options:options l builds a command extract elements from the data it receives,
passing options to the cut executable. options defaults to [].val sleep : int -> ([ `No_input ], [ `No_output ], [ `No_error ]) commandsleep x suspends the execution for x seconds.val pipe : ([< `Input | `No_input ] as 'a, [ `Output ], [< `Error | `No_error ])
command ->
([ `Input ], [< `No_output | `Output ] as 'b, [< `Error | `No_error ] as 'c)
command -> ('a, 'b, 'c) commandpipe c1 c2 builds a command that is equivalent to c1 piped to c2.val (|>) : ([< `Input | `No_input ] as 'a, [ `Output ], [< `Error | `No_error ])
command ->
([ `Input ], [< `No_output | `Output ] as 'b, [< `Error | `No_error ] as 'c)
command -> ('a, 'b, 'c) commandpipe.val redirect_output : ([< `Input | `No_input ] as 'a, [ `Output ], [< `Error | `No_error ] as 'b)
command -> string -> ('a, [ `No_output ], 'b) commandredirect_output c f builds a command that redirect the output of command c to file f.val (>>) : ([< `Input | `No_input ] as 'a, [ `Output ], [< `Error | `No_error ] as 'b)
command -> string -> ('a, [ `No_output ], 'b) commandredirect_output.val redirect_append : ([< `Input | `No_input ] as 'a, [ `Output ], [< `Error | `No_error ] as 'b)
command -> string -> ('a, [ `No_output ], 'b) commandredirect_append c f builds a command that redirect the output of command c to file f in append mode.val (>>>) : ([< `Input | `No_input ] as 'a, [ `Output ], [< `Error | `No_error ] as 'b)
command -> string -> ('a, [ `No_output ], 'b) commandredirect_append.val redirect_error : ([< `Input | `No_input ] as 'a, [< `No_output | `Output ] as 'b, [ `Error ])
command -> string -> ('a, 'b, [ `No_error ]) commandredirect_error c f builds a command that redirect the error of command c to file f.val (>>>>) : ([< `Input | `No_input ] as 'a, [< `No_output | `Output ] as 'b, [ `Error ])
command -> string -> ('a, 'b, [ `No_error ]) commandredirect_error.val redirect_append_error : ([< `Input | `No_input ] as 'a, [< `No_output | `Output ] as 'b, [ `Error ])
command -> string -> ('a, 'b, [ `No_error ]) commandredirect_error c f builds a command that redirect the error of command c to file f in append mode.val (>>>>>) : ([< `Input | `No_input ] as 'a, [< `No_output | `Output ] as 'b, [ `Error ])
command -> string -> ('a, 'b, [ `No_error ]) commandredirect_append_error.