Skip to content

Invalid environment variable names for Command are not rejected #101978

Open
@dylni

Description

@dylni

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-processArea: `std::process` and `std::env`C-bugCategory: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions