Env

Env :: # (opaque)

Read and modify the process environment without losing native OS strings.

Variable names and values use OsStr because Unix environment data is not required to be UTF-8. Use var_str! when an application specifically requires text. Paths use basic-cli's byte-preserving Path type.

platform! : => { arch : [X86, X64, ARM, AARCH64, OTHER(Str)], os : [LINUX, MACOS, WINDOWS, OTHER(Str)], }

Report the architecture and operating system for which the host was built.

dict! : => List((OsStr, OsStr))

Return all environment variables as native name/value pairs.

Native non-Unicode values are preserved. Iteration order is unspecified and may differ between calls or operating systems.

var! : OsStr => Try(OsStr, [VarNotFound(OsStr), EnvErr(IOErr), ..])

Reads the given environment variable.

Returns Err(VarNotFound(name)) if the variable is not set.

var_str! : OsStr => Try(Str, [VarNotFound(OsStr), EnvErr(IOErr), InvalidStr(U64), ..])

Reads the given environment variable as a string if its native value is valid text.

set_cwd! : Path => Try({ }, [InvalidCwd(IOErr), ..])

Change the process current working directory.

Returns Err(InvalidCwd(err)) when the path cannot be used as a working directory. The process-wide change remains in effect until changed again.

exe_path! : => Try(Path, [ExePathUnavailable, ..])

Gets the path to the currently-running executable.

Returns Err(ExePathUnavailable) if the path cannot be determined.

temp_dir! : => Path

Gets the default directory for temporary files.