MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / env_set

Function env_set

aiscript-vm/src/stdlib/env.rs:68–80  ·  view source on GitHub ↗

Sets the value of an environment variable

(_state: &mut State<'gc>, args: Vec<Value<'gc>>)

Source from the content-addressed store, hash-verified

66
67// Sets the value of an environment variable
68fn env_set<'gc>(_state: &mut State<'gc>, args: Vec<Value<'gc>>) -> Result<Value<'gc>, VmError> {
69 if args.len() != 2 {
70 return Err(VmError::RuntimeError(
71 "set_env() requires two arguments: variable name and value".into(),
72 ));
73 }
74
75 let var_name = args[0].as_string()?.to_str().unwrap();
76 let value = args[1].as_string()?.to_str().unwrap();
77
78 unsafe { std::env::set_var(var_name, value) };
79 Ok(Value::Nil)
80}

Callers

nothing calls this directly

Calls 4

RuntimeErrorClass · 0.85
lenMethod · 0.80
to_strMethod · 0.80
as_stringMethod · 0.80

Tested by

no test coverage detected