Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
vadimcn opened this issue Sep 2, 2014 · 0 comments · Fixed by #17249
Closed

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

vadimcn opened this issue Sep 2, 2014 · 0 comments · Fixed by #17249
Labels
O-windows Operating system: Windows

Comments

@vadimcn
Copy link
Contributor

vadimcn commented Sep 2, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows Operating system: Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants