Function in env compiler

remove_var

fn remove_var(string name) -> Result<unit, EnvError>
Import
use env::{remove_var};
Source: compiler/src/builtin_docs/env.hy

Removes the environment variable name from this process.

Removing a variable that is not set is not an error. Needs --allow-env.

Parameters#

NameType
namestring

Returns#

Result<unit, EnvError>

Examples#

use env::{set_var, remove_var, var, EnvError};
use tests::assert;
let _ = set_var("COIL_DOC_TMP", "1");
let _ = remove_var("COIL_DOC_TMP");
let gone = match var("COIL_DOC_TMP") {
    Result::Err(EnvError::NotFound) => true,
    default => false,
};
assert!(gone);

See also#

  • args: Returns the program’s command-line arguments, starting with the program name.
  • var: Returns the value of the environment variable name.
  • set_var: Sets the environment variable name to value for 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 status code.
  • exec: Runs program with the arguments argv and waits for it to finish.
↑ ↓ navigate ↵ open