summaryrefslogtreecommitdiffstats
path: root/src/env.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2022-01-08 04:27:59 -0500
committerJesse Luehrs <doy@tozt.net>2022-01-08 04:27:59 -0500
commit71df59851586f7221accf95289962fe61c63fb90 (patch)
tree7ccf57591d40bda223a06dbefbac54dd0bb092b2 /src/env.rs
parent91418540883b5732f5af1060975d583043a5886d (diff)
downloadnbsh-71df59851586f7221accf95289962fe61c63fb90.tar.gz
nbsh-71df59851586f7221accf95289962fe61c63fb90.zip
add setenv and unsetenv builtins
Diffstat (limited to 'src/env.rs')
-rw-r--r--src/env.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/env.rs b/src/env.rs
index e6cbe9c..221182e 100644
--- a/src/env.rs
+++ b/src/env.rs
@@ -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(())
}