package core_unix

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type t = [
  1. | `Replace of (string * string) list
  2. | `Extend of (string * string) list
  3. | `Override of (string * string option) list
  4. | `Replace_raw of string list
]

t is used to control the environment of a child process, and can take four forms. `Replace_raw replaces the entire environment with strings in the Unix style, like "VARIABLE_NAME=value". `Replace has the same effect as `Replace_raw, but using bindings represented as "VARIABLE_NAME", "value". `Extend adds entries to the existing environment rather than replacing the whole environment. `Override is similar to `Extend but allows unsetting variables too.

If env contains multiple bindings for the same variable, the last takes precedence. In the case of `Extend, bindings in env take precedence over the existing environment.

val sexp_of_t : t -> Sexplib0.Sexp.t
val t_of_sexp : Sexplib0.Sexp.t -> t
val __t_of_sexp__ : Sexplib0.Sexp.t -> t
val expand : ?base:string list Core.Lazy.t -> t -> string list

expand ?base t returns the environment resulting from applying the changes described by t on the given base environment, defaulting to current environment. It can be useful to use the type t on functions that only take the full environment, like Spawn.spawn or open_process_full. It can also be useful, when passing a base, to combine multiple t by applying them in succession.

val expand_array : ?base:string list Core.Lazy.t -> t -> string array

expand_array t is a shorthand for Array.of_list (expand t).