rust icon indicating copy to clipboard operation
rust copied to clipboard

Invalid environment variable names for `Command` are not rejected

Open dylni opened this issue 3 years ago • 0 comments

I tried this code:

use std::process::Command;

fn main() {
    println!(
        "{:?}",
        Command::new("printenv")
            .arg("foo")
            .env("foo=bar", "baz")
            .output()
    );
}

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f3e035599c38c2bea88c8331a0b94da1

I expected to see this happen: an error that the environment variable name contains =

Instead, this happened:

Ok(Output { status: ExitStatus(unix_wait_status(0)), stdout: "bar=baz\n", stderr: "" })

There was a PR for to give errors for these variables, but it was closed due to inactivity: #39338

Meta

rustc --version:

rustc 1.63.0 (4b91a6ea7 2022-08-08)

dylni avatar Sep 18 '22 13:09 dylni