diff options
author | Jesse Luehrs <doy@tozt.net> | 2022-01-08 04:27:59 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2022-01-08 04:27:59 -0500 |
commit | 71df59851586f7221accf95289962fe61c63fb90 (patch) | |
tree | 7ccf57591d40bda223a06dbefbac54dd0bb092b2 /src/env.rs | |
parent | 91418540883b5732f5af1060975d583043a5886d (diff) | |
download | nbsh-71df59851586f7221accf95289962fe61c63fb90.tar.gz nbsh-71df59851586f7221accf95289962fe61c63fb90.zip |
add setenv and unsetenv builtins
Diffstat (limited to 'src/env.rs')
-rw-r--r-- | src/env.rs | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -96,6 +96,17 @@ impl Env { } } + pub fn set_vars( + &mut self, + it: impl Iterator<Item = (std::ffi::OsString, std::ffi::OsString)>, + ) { + match self { + Self::V0(env) => { + env.vars = it.collect(); + } + } + } + pub fn apply(&self, cmd: &mut pty_process::Command) { match self { Self::V0(env) => { @@ -108,6 +119,7 @@ impl Env { pub fn update(&mut self) -> anyhow::Result<()> { self.set_current_dir(std::env::current_dir()?); + self.set_vars(std::env::vars_os()); Ok(()) } |