Windows: process::Command::env should be case-insensitive

d5399c0
Opened by vadimcn at 2014-09-18 18:45:42

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.