package containers

  1. Overview
  2. Docs

High-level Functions on top of Unix

Some useful functions built on top of Unix.

status: unstable

  • since 0.10
type 'a or_error = [
  1. | `Ok of 'a
  2. | `Error of string
]
type 'a gen = unit -> 'a option

Calling Commands

val escape_str : Buffer.t -> string -> unit

Escape a string so it can be a shell argument.

type call_result = < stdout : string ; stderr : string ; status : Unix.process_status ; errcode : int >
val call : ?bufsize:int -> ?stdin:[ `Gen of string gen | `Str of string ] -> ?env:string array -> ('a, Buffer.t, unit, call_result) Pervasives.format4 -> 'a

call cmd wraps the result of Unix.open_process_full cmd into an object. It reads the full stdout and stderr of the subprocess before returning.

  • parameter stdin

    if provided, the generator or string is consumed and fed to the subprocess input channel, which is then closed.

  • parameter bufsize

    buffer size used to read stdout and stderr

  • parameter env

    environment to run the command in

OCaml

Innovation. Community. Security.