rust
rust copied to clipboard
Invalid environment variable names for `Command` are not rejected
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)