package MlFront_Core

  1. Overview
  2. Docs

Module MlFront_Core.EnvModsSource

Sourcetype t
Sourceval empty : t

empty is an empty set of environment modifications.

Sourceval pp : Format.formatter -> t -> unit

pp ppf envmods is a pretty-printer of the environment modifications envmods.

Sourceval show : t -> string

show envmods is a pretty printing of the environment modifications envmods.

Sourceval additions : t -> (string * string) list

additions mods are the set of (name,value) environment additions.

Additions should always be processed before removals and path_prepends.

Sourceval path_prepends : t -> (string * string) list

path_prepends mods are the list of (name,value) environment additions for PATH-like variables.

Each (name,value) pair should be prepended in order.

Additions should always be processed before path prepends.

Path prepends should always be processed before removals.

Sourceval removals : t -> string list

removals mods are the set of environment names that need to be removed.

Removals should always be processed after additions.

Sourceval add : string -> string -> t -> t

add name value mods adds the environment variable named name with the value value to the environment.

Sourceval prepend_path : string -> string -> t -> t

prepend_path name value mods prepends to the PATH-like environment variable name the value value.

On Windows the path environment variable will be separated by semicolons while Unix will be seperated by colons.

Sourceval add_from_env_if_present : win32:bool -> string list -> (string * string) list -> t -> t

add_from_env_if_present ~win32 names env_bindings t adds the subset of (name,value) environment bindings from env_bindings whose names match names.

For the "Bos" package with its "OS.Cmd.run" family of command runners, you should use ~win32:Sys.win32 (Astring.String.Map bindings env).

For the same "OS.Cmd.run" in the dk coder, which does not have Astring, you should use ~win32:Sys.win32 (Bos.OSEnvMap.bindings env).

Sourceval remove_names : string list -> t -> t

remove_names name mods removes the environment variable named name from the environment.

Sourceval union : t -> t -> t

union a b is all the modifications from both b and a, with preference given to b when an environment variable addition is present in both b and a.

Sourceval apply : win32:bool -> t -> (string * string) list -> (string * string) list

apply ~win32 mods env_bindings applies the modifications mods to the (name,value) environment bindings in env_bindings.

For the "Bos" package with its "OS.Cmd.run" family of command runners, you should use:

  MlFront_Core.EnvMods.apply ~win32:Sys.win32 envmods
    (Astring.String.Map.bindings env)
  |> Astring.String.Map.of_list

For the same "OS.Cmd.run" in the dk coder, which does not have Astring, you should use:

  MlFront_Core.EnvMods.apply ~win32:Sys.win32 envmods
    (Tr1Bos_Std.Bos.OSEnvMap.bindings env_orig)
  |> Tr1Stdlib_V414Base.List.to_seq |> Tr1Bos_Std.Bos.OSEnvMap.of_seq