set_var
fn set_var(string name, string value) -> Result<unit, EnvError> Import
Source: use env::{set_var}; compiler/src/builtin_docs/env.hy Sets the environment variable name to value for this process.
Programs started later with exec inherit it. A name or value with a
NUL byte is Err(EnvError::InvalidInput). Needs --allow-env.
Parameters#
| Name | Type |
|---|---|
name | string |
value | string |
Returns#
Result<unit, EnvError>
Examples#
use env::{set_var, var, remove_var};
use tests::assert;
assert!(match set_var("COIL_DOC_MODE", "test") { Result::Ok(_) => true, Result::Err(_) => false });
assert!(match var("COIL_DOC_MODE") { Result::Ok(s) => s == "test", Result::Err(_) => false });
let _ = remove_var("COIL_DOC_MODE");
See also#
env::execargs: Returns the program’s command-line arguments, starting with the program name.var: Returns the value of the environment variablename.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.