Environment module

environment_variable

procedureextensionsince 0.31.0Source

The value of the environment variable name, in temporary storage, or "" when it is not set. On Windows the name and value go through UTF-16, so non-ASCII values come back as UTF-8.

The string is valid until the temporary storage is reset: use copy_string to keep it. A name that is not set, and one that cannot be looked up (an empty name or, on Windows, text that is not valid UTF-8), give "" as well; use has_environment_variable to tell an empty value from an unset variable.

Example
assert(environment_variable("PATH").count > 0); // set on every desktop platform
assert(environment_variable("JAI_DOC_SURELY_UNSET_VARIABLE") == "");

kept := copy_string(environment_variable("PATH"));
defer free(kept);
assert(kept.count > 0);

Doesn't run in the browser (skipped on wasm).

environment_variable :: (name: string) -> string

Parameters

name: string

Returns

string

See also