OS
Module
Implements basic routines for working with the OS.
getenv
getenv(name: StringRef, default: StringRef) -> StringRef
Returns the value of the given environment variable.
Constraints:
The function only works on macOS or Linux and returns an empty string otherwise.
Args:
- name (
StringRef
): The name of the environment variable. - default (
StringRef
): The default value to return if the environment variable doesn’t exist.
Returns:
The value of the environment variable.
getenv(name: StringRef) -> StringRef
Returns the value of the given environment variable.
Args:
- name (
StringRef
): The name of the environment variable.
Returns:
The value of the environment variable, or empty string if it doesn’t exist.
setenv
setenv(name: StringRef, value: StringRef, overwrite: Bool) -> Bool
Change or add an environment variable.
Constraints:
The function only works on macOS or Linux and returns False otherwise.
Args:
- name (
StringRef
): The name of the environment variable. - value (
StringRef
): The value of the environment variable. - overwrite (
Bool
): If an environment variable with the given name already exists, its value is not changed unlessoverwrite
is True.
Returns:
False if the name is empty or contains an =
character. In any other case, True is returned.