Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
Shell command representation.
This module is used for the subset of the shell language that is needed to operate remote runners through SSH. It makes sure that shell command are properly quoted.
Commands.
Commands execute a program (whose executable name is name
), with some arguments
, possibly with some specific environment variables local_env
to add to the current environment.
type t =
| Cmd of command
run a command
*)| Seq of t * t
run something, then something else (;
)
| Echo_pid
echo the current process PID (echo $$
)
| Redirect_stdout of t * string
redirect stdout to a file (>
)
| Redirect_stderr of t * string
redirect stderr to a file (2>
)
| Or_echo_false of t
run something, if it fails, print "false" (|| echo false
)
Shell programs.
val to_string : ?context:[ `operator | `top ] -> t -> string
Convert a shell program into a string.
The result is quoted using shell syntax.
context
specifies whether parentheses are needed:
`top
means no parentheses are needed (default);`operator
means parentheses may be needed because this command is inside of an operator such as ;
or ||
.val cmd : (string * string) list -> string -> string list -> t
Make a command to execute a program.
Usage: cmd local_env name arguments
Same as: Cmd { local_env; name; arguments }
Make a sequence.
Usage: seq command_1 command_2
Same as: Seq (command_1, command_2)
Make an stdout redirection.
Usage: redirect_stdout command path
Same as: Redirect_stdout (command, path)
Make an stderr redirection.
Usage: redirect_stderr command path
Same as: Redirect_stderr (command, path)