Module Os.Env
Environment variables.
Variables
val find : empty_to_none:bool -> string -> string option
find ~empty_to_none name
is the value of the environment variablename
in the current process environment, if defined. Ifempty_to_none
istrue
(default),None
is returned if the variable value is the empty string.
val find_value : (string -> ('a, string) Stdlib.result) -> empty_to_none:bool -> string -> ('a, string) Stdlib.result option
find_value parse ~empty_to_none name
isOption.bind parse (find ~empty_to_none name)
, except the error message ofparse
is tweaked to mentionname
in case of error.
Process environement
type t
= string String.Map.t
The type for process environments.
val empty : t
empty
isString.Map.empty
.
val current : unit -> (t, string) Stdlib.result
current ()
is the current process environment.
Process environments as assignments
type assignments
= string list
The type for environments as lists of strings of the form
"var=value"
.
val current_assignments : unit -> (assignments, string) Stdlib.result
current_assignments ()
is the current process environment as assignments.
val of_assignments : ?init:t -> string list -> (t, string) Stdlib.result
of_assignments ~init ss
folds over strings inss
, cuts them at the leftmost'='
character and adds the resulting pair toinit
(defaults toempty
). If the same variable is bound more than once, the last one takes over.
val to_assignments : t -> assignments
to_assignments env
isenv
's bindings as assignments.