API Reference › Os › Os.env
method

Os.env

Os.env(name) -> string

Reads an environment variable and returns its value, or null when the variable is not set. Use env_or when you want a fallback, or has_env to test presence without risking a null.

Parameters

namethe variable name

Example

program Env {
  entry {
    if Os.has_env("HOME") {
      let home = Os.env("HOME")
      print(len(home))
    }
  }
}
← All symbols