Skip to content

Command::env doesn't report an error for keys with = in them #122335

Open
@5225225

Description

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

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

This has a stdout of bar=baz, so the foo key has value bar=baz.

Which isn't what I asked for in env, but what I asked for is invalid.

We probably shouldn't panic from a bad env call, but this program shouldn't be able to spawn without erroring.

I assume .env("foo=bar", "baz").env_remove("foo=bar") shouldn't error. (Also, not sure how non-unix platforms handle this, but this validation should presumably be platform-specific).

I'm not sure if this is a bug or just weird behavior.

Metadata

Metadata

Assignees

Labels

C-discussionCategory: Discussion or questions that doesn't represent real issues.T-libs-apiRelevant to the library API 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