1
Fork 0

Fix Windows Command::env("PATH")

This commit is contained in:
Chris Denton 2021-08-08 14:23:08 +01:00
parent e8c25f2663
commit 419902e413
No known key found for this signature in database
GPG key ID: 713472F2F45627DE
2 changed files with 30 additions and 9 deletions

View file

@ -65,16 +65,18 @@ impl CommandEnv {
// The following functions build up changes
pub fn set(&mut self, key: &OsStr, value: &OsStr) {
let key = EnvKey::from(key);
self.maybe_saw_path(&key);
self.vars.insert(key.to_owned().into(), Some(value.to_owned()));
self.vars.insert(key, Some(value.to_owned()));
}
pub fn remove(&mut self, key: &OsStr) {
let key = EnvKey::from(key);
self.maybe_saw_path(&key);
if self.clear {
self.vars.remove(key);
self.vars.remove(&key);
} else {
self.vars.insert(key.to_owned().into(), None);
self.vars.insert(key, None);
}
}
@ -87,7 +89,7 @@ impl CommandEnv {
self.saw_path || self.clear
}
fn maybe_saw_path(&mut self, key: &OsStr) {
fn maybe_saw_path(&mut self, key: &EnvKey) {
if !self.saw_path && key == "PATH" {
self.saw_path = true;
}