var
fn var(string name) -> Result<string, EnvError> Import
Source: use env::{var}; compiler/src/builtin_docs/env.hy Returns the value of the environment variable name.
Returns Err(EnvError::NotFound) when it is not set and
Err(EnvError::Other) when its value is not valid UTF-8. Needs
--allow-env.
Parameters#
| Name | Type |
|---|---|
name | string |
Returns#
Result<string, EnvError>
Examples#
use env::{var, set_var};
use tests::assert;
let _ = set_var("COIL_DOC_GREETING", "hello");
let v = match var("COIL_DOC_GREETING") {
Result::Ok(s) => s,
Result::Err(_) => "",
};
assert!(v == "hello");
See also#
args: Returns the program’s command-line arguments, starting with the program name.set_var: Sets the environment variablenametovaluefor this process.remove_var: Removes the environment variablenamefrom this process.cwd: Returns the current working directory as an absolute path.set_cwd: Changes the current working directory of the whole process.exit: Ends the process at once with exit statuscode.exec: Runsprogramwith the argumentsargvand waits for it to finish.