mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 19:27:44 +02:00
Add unlet_env
command (#3629)
* Add ability to remove env variables Signed-off-by: nathom <nathanthomas707@gmail.com> * Implement unlet_env command Signed-off-by: nathom <nathanthomas707@gmail.com> * Update parameter description Signed-off-by: nathom <nathanthomas707@gmail.com> * Migrate to new filestructure Signed-off-by: nathom <nathanthomas707@gmail.com> * Added tests for unlet-env Signed-off-by: nathom <nathanthomas707@gmail.com> * Formatting Signed-off-by: nathom <nathanthomas707@gmail.com>
This commit is contained in:
@ -239,6 +239,15 @@ impl Scope {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_env_var(&self, name: impl Into<String>) -> Option<String> {
|
||||
if let Some(frame) = self.frames.lock().last_mut() {
|
||||
if let Some(val) = frame.env.remove_entry(&name.into()) {
|
||||
return Some(val.1);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn add_env(&self, env_vars: IndexMap<String, String>) {
|
||||
if let Some(frame) = self.frames.lock().last_mut() {
|
||||
frame.env.extend(env_vars)
|
||||
|
Reference in New Issue
Block a user