-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
O-windowsOperating system: WindowsOperating system: Windows
Description
The following program demonstrates the problem:
use std::io::process;
fn main() {
let mut cmd = process::Command::new("cmd.exe");
cmd.arg("/C").arg("echo %FOO%");
cmd.env("foo", "foo");
cmd.env("FOO", "BAR");
cmd.stdout(process::InheritFd(1));
cmd.spawn();
}
When compiled and executed on WIndows, it randomly displays either 'foo' or 'BAR'.
This happens because process::Command represents environment block as a HasMap<CString, CString>, so it treats "foo" and "FOO" as different variables, whereas Windows considers them to be the same one. When child process is spawned, both get added into the environment block, however Windows keeps only the last one.
Metadata
Metadata
Assignees
Labels
O-windowsOperating system: WindowsOperating system: Windows