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 v
if(name, v)
is in the environmentenv
. Otherwise, it returnsNONE
ifname
is not bound inenv
. val getValue : {name : string, default : string, env : string list} -> string
-
getEnv {name, default, env}
returnsv
if(name, v)
is in the environmentenv
. Otherwise, it returnsdefault
ifname
is not bound inenv
. val removeFromEnv : (string * string list) -> string list
-
removeFromEnv (name, env)
removes any binding ofname
from the environment. Note that ifenv
has multiple bindings ofname
(i.e.,env
is 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 ofname
inenv
, then it will be replaced. val environ : unit -> string list
-
env ()
returns the user’s (host process) environment. val getEnv : string -> string option
-
getEnv name
returns the binding of the environment variablename
in the user’s (host process) environment.