Module Unix.Env

Functions for Manipulating the Environment

Unix.environment is a low-level function that returns an array of strings formatted like "PAGER=less". The functions in this module allow you to work with a friendlier environment represented as an association list of variable names and values ("PAGER", "less"). Also useful with Sys.runtime_parameters.

val to_alist : string array -> (string * string) list

to_alist converts a Unix.environment-like string array into an alist.

val env : unit -> (string * string) list

(env ()) is (Unix.environment () |> to_alist)

val of_alist : (string * string) list -> string array

of_alist converts an alist to a Unix.environment-like string array; N.B. it does NOT actually change the environment!

The result is suitable for passing to functions like Unix.execve and Proc.runfull.