diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2018-03-23 09:27:10 -0500 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2018-03-23 10:16:07 -0700 |
| commit | 16eeb10bee51286d616f0d5de9f32b9b48aa4dc3 (patch) | |
| tree | 771e4d2af0703ee15c6c74849a26e7c13bce5f91 /src/libstd/sys_common | |
| parent | 7cf4cb5a7be38fcb3831204eb32ad6e2ef0a9e25 (diff) | |
| parent | 70559c54ce2a493a15f447436e281e16fc55b291 (diff) | |
| download | rust-16eeb10bee51286d616f0d5de9f32b9b48aa4dc3.tar.gz rust-16eeb10bee51286d616f0d5de9f32b9b48aa4dc3.zip | |
Rollup merge of #48624 - bdrewery:freebsd-posix-spawn, r=alexcrichton
Command: Support posix_spawn() on FreeBSD/OSX/GNU Linux
Diffstat (limited to 'src/libstd/sys_common')
| -rw-r--r-- | src/libstd/sys_common/process.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libstd/sys_common/process.rs b/src/libstd/sys_common/process.rs index fd1a5fdb410..d0c5951bd6c 100644 --- a/src/libstd/sys_common/process.rs +++ b/src/libstd/sys_common/process.rs @@ -47,6 +47,7 @@ impl EnvKey for DefaultEnvKey {} #[derive(Clone, Debug)] pub struct CommandEnv<K> { clear: bool, + saw_path: bool, vars: BTreeMap<K, Option<OsString>> } @@ -54,6 +55,7 @@ impl<K: EnvKey> Default for CommandEnv<K> { fn default() -> Self { CommandEnv { clear: false, + saw_path: false, vars: Default::default() } } @@ -108,9 +110,11 @@ impl<K: EnvKey> CommandEnv<K> { // The following functions build up changes pub fn set(&mut self, key: &OsStr, value: &OsStr) { + self.maybe_saw_path(&key); self.vars.insert(key.to_owned().into(), Some(value.to_owned())); } pub fn remove(&mut self, key: &OsStr) { + self.maybe_saw_path(&key); if self.clear { self.vars.remove(key); } else { @@ -121,4 +125,12 @@ impl<K: EnvKey> CommandEnv<K> { self.clear = true; self.vars.clear(); } + pub fn have_changed_path(&self) -> bool { + self.saw_path || self.clear + } + fn maybe_saw_path(&mut self, key: &OsStr) { + if !self.saw_path && key == "PATH" { + self.saw_path = true; + } + } } |
