The UnixEnv structure supports operations on the host process’s environment,
which is essentially a list of strings of the form “`name=value`”, where
the “=” character does not appear in name. We assume that environments
are "well formed;" i.e., that an environment variable is only defined once.
|
Warning
|
Binding the user’s environment as an SML value and then exporting the SML heap image can result in incorrect behavior, since the environment bound in the heap image may differ from the user’s environment when the exported heap image is loaded. |
Synopsis
signature UNIX_ENV
structure UnixEnv : UNIX_ENV
Interface
val getFromEnv : (string * string list) -> string option
val getValue : {name : string, default : string, env : string list} -> string
val removeFromEnv : (string * string list) -> string list
val addToEnv : (string * string list) -> string list
val environ : unit -> string list
val getEnv : string -> string option
Description
val getFromEnv : (string * string list) -> string option-
getEnv (name, env)returnsSOME vif(name, v)is in the environmentenv. Otherwise, it returnsNONEifnameis not bound inenv. val getValue : {name : string, default : string, env : string list} -> string-
getEnv {name, default, env}returnsvif(name, v)is in the environmentenv. Otherwise, it returnsdefaultifnameis not bound inenv. val removeFromEnv : (string * string list) -> string list-
removeFromEnv (name, env)removes any binding ofnamefrom the environment. Note that ifenvhas multiple bindings ofname(i.e.,envis not well formed), then only the first binding is removed. val addToEnv : (string * string list) -> string list-
addToEnv (bind, env)adds the bindingbind, which should be of the form “`name=value`”, to the environment. If there was an existing binding ofnameinenv, then it will be replaced. val environ : unit -> string list-
env ()returns the user’s (host process) environment. val getEnv : string -> string option-
getEnv namereturns the binding of the environment variablenamein the user’s (host process) environment.