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 : configuration
val set_configuration : configuration -> unit
set_configuration c
changes the configuration to c
.
The default configuration is bash
.
val read_lines : string -> string list
read_lines file
returns the lines from file file
.
Raises an exception if an i/o error occurs.val write_lines : string list -> string -> unit
write_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 ])
command
command 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 ])
command
coerce 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 ]) command
coerce
that ignores both outputs.val run : ([< `Input | `No_input ], [< `No_output | `Output ], [< `Error | `No_error ])
command -> int
run c
runs the command c
, returning its exit code.val run_list : ([< `Input | `No_input ], [< `No_output | `Output ], [< `Error | `No_error ])
command list -> int
val file_exists : string -> bool
Sys.file_exists
.val is_directory : string -> bool
Sys.is_directory
.val getenv : string -> string
Sys.getenv
.val files : string -> string list
Sys.readdir
except that a list is returned.val files_with_filter : (string -> bool) -> string -> string list
files
except that the returned list is filtered by
the passed function.val files_with_suffix : string -> string -> string list
files_with_suffix s d
equivalent to files d
except that only
the files with the suffix s
are returned.val current_dir_name : string
Filename.current_dir_name
.val parent_dir_name : string
Filename.parent_dir_name
.val is_relative : string -> bool
Filename.is_relative
.val is_implicit : string -> bool
Filename.is_implicit
.val check_suffix : string -> string -> bool
Filename.check_suffix
.val chop_suffix : string -> string -> string
Filename.chop_suffix
.val chop_extension : string -> string
Filename.chop_extension
.val basename : string -> string
Filename.basename
.val dirname : string -> string
Filename.dirname
.val concatname : string -> string -> string
Filename.concatname
.val temp_file : ?temp_dir:string -> string -> string -> string
Filename.temp_file
.val quote : string -> string
Filename.quote
.val pwd : unit -> string
val cd : string -> unit
Sys_error
if the directory does not exist.val pushd : string -> unit
Sys_error
if the directory does not exist.val popd : unit -> string
Stack.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 ]) command
exit n
builds a command returning the exit code n
.val pwdir : unit -> ([ `No_input ], [ `Output ], [ `No_error ]) command
pwd
, as a command.val chdir : string -> ([ `No_input ], [ `No_output ], [ `Error ]) command
cd
, as a command.val mkdir : ?options:string list ->
string -> ([ `No_input ], [ `No_output ], [ `Error ]) command
mkdir ~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 ]) command
rmdir ~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 ]) command
ls ~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 ]) command
cp ~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 ]) command
rm ~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 ]) command
mv ~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 ]) command
touch ~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 ]) command
cat ~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 ]) command
echo ~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 ]) command
diff ~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 ]) command
grep ~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 ]) command
grep_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 ]) command
sed ~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 ]) command
sed ~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 ]) command
cut ~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 ]) command
sleep 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) command
pipe 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) command
pipe
.val redirect_output : ([< `Input | `No_input ] as 'a, [ `Output ], [< `Error | `No_error ] as 'b)
command -> string -> ('a, [ `No_output ], 'b) command
redirect_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) command
redirect_output
.val redirect_append : ([< `Input | `No_input ] as 'a, [ `Output ], [< `Error | `No_error ] as 'b)
command -> string -> ('a, [ `No_output ], 'b) command
redirect_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) command
redirect_append
.val redirect_error : ([< `Input | `No_input ] as 'a, [< `No_output | `Output ] as 'b, [ `Error ])
command -> string -> ('a, 'b, [ `No_error ]) command
redirect_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 ]) command
redirect_error
.val redirect_append_error : ([< `Input | `No_input ] as 'a, [< `No_output | `Output ] as 'b, [ `Error ])
command -> string -> ('a, 'b, [ `No_error ]) command
redirect_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 ]) command
redirect_append_error
.