about summary refs log tree commit diff
path: root/src/librustc_codegen_ssa/back/command.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/librustc_codegen_ssa/back/command.rs')
-rw-r--r--src/librustc_codegen_ssa/back/command.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/librustc_codegen_ssa/back/command.rs b/src/librustc_codegen_ssa/back/command.rs
index 340cc772e5f..596978f002b 100644
--- a/src/librustc_codegen_ssa/back/command.rs
+++ b/src/librustc_codegen_ssa/back/command.rs
@@ -14,6 +14,7 @@ pub struct Command {
     program: Program,
     args: Vec<OsString>,
     env: Vec<(OsString, OsString)>,
+    env_remove: Vec<OsString>,
 }
 
 #[derive(Clone)]
@@ -41,6 +42,7 @@ impl Command {
             program,
             args: Vec::new(),
             env: Vec::new(),
+            env_remove: Vec::new(),
         }
     }
 
@@ -75,6 +77,17 @@ impl Command {
         self.env.push((key.to_owned(), value.to_owned()));
     }
 
+    pub fn env_remove<K>(&mut self, key: K) -> &mut Command
+        where K: AsRef<OsStr>,
+    {
+        self._env_remove(key.as_ref());
+        self
+    }
+
+    fn _env_remove(&mut self, key: &OsStr) {
+        self.env_remove.push(key.to_owned());
+    }
+
     pub fn output(&mut self) -> io::Result<Output> {
         self.command().output()
     }
@@ -100,6 +113,9 @@ impl Command {
         };
         ret.args(&self.args);
         ret.envs(self.env.clone());
+        for k in &self.env_remove {
+            ret.env_remove(k);
+        }
         return ret
     }