(** Functions to execute shell commands *) (** These are the elements that constitute the output of a shell command *) type elem = Stdout of string | Stderr of string | Exit of int | Stopped of int | Signaled of int | Open (** Means we exited before the shell command *) val to_stream : string -> elem Stream.t (** Return a stream of Sh.elem from a shell command. This function should be able to handle any amount of output from stdout and stderr. Note that it is not possible to send anything to the process standard input. If we want to do this we need a different structure: [let ichan = run stdout_function stderr_function cmd] *) val to_stringstream : string -> string Stream.t (** Return a stream of the strings written to stdout only *) val to_linestream : string -> string Stream.t (** Return a stream of the lines printed by a command. Terminating newline characters are omitted. *) val to_linelist : string -> string list (** Return a list of the lines returned by [to_linestream] *) val to_strings : string -> string * string * elem (** Collect all the process output and return a triple: (stdout, stderr, exitstatus) *) val to_string : string -> string * elem (** Like [to_strings], but omits stderr. *) val line1 : string -> string option (** Return the first line of a shell command's output *) (** Run a shell command and raise an exception if it fails. *) val run : string -> unit (** Same thing, but print the command on stderr before running *) val vrun : string -> unit (** Send a stream's contents to a command's standard input *) val stream_in : string -> string Stream.t -> unit (** Run a shell command and send stdout and stderr to the two function arguments line by line. *) val filter_old : (string -> 'a) -> (string -> 'b) -> string -> unit (** Version of filter based on to_stream. Returns the last element, which is the first element that isn't stdout or stderr. *) val filter : (string -> unit) -> (string -> unit) -> string -> elem (* Stuff that is more or less deprecated (meaning I don't like it.) *) (* val strict_closer : in_channel -> unit val closer : in_channel -> unit val lax_closer : in_channel -> unit *) (* We declare an exception and a value to represent each type of process termination. This allows maximum flexibility of choosing whether a given result is a normal or an exceptional condition. *) (* Disabled until thread support gets enabled. *) (* exception ExitExn of int exception StoppedExn of int exception SignaledExn of int type process_result = Exit of int | Stopped of int | Signaled of int val filter3 : ?instream:string Stream.t -> ?outfn:(string -> int -> int -> unit) -> ?errfn:(string -> int -> int -> unit) -> ?onexit:(int -> process_result) -> ?onstop:(int -> process_result) -> ?onsignal:(int -> process_result) -> string -> process_result *) module Old : sig type closer = Strict | Normal | Lax val string : ?closer:closer -> string -> string end