Skip to content

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

Closed
@vadimcn

Description

@vadimcn

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

No one assigned

    Labels

    O-windowsOperating system: Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions