Skip to content

Introduce a interfaces to expose the current Command captured env var logic #149070

@schneems

Description

@schneems

Feature gate: #![feature(command_resolved_envs)]

This is a tracking issue for the API Change Proposal (ACP) rust-lang/libs-team#194.

This feature adds two methods to std::process::Command to expose environment variable resolution logic, addressing the inability to observe the effects of env_clear() and the lack of a single source of truth for environment variable resolution.

Public API

// std::process

impl Command {
    pub fn get_env_clear(&self) -> bool;
    pub fn get_resolved_envs(&self) -> impl Iterator<Item = (OsString, OsString)>;
}

Explanation:

  • get_env_clear This makes sure people have all the information Command stores.
  • get_resolved_envs This should include documentation that says it returns the environment as it would be if the command were executed at that point, and will not match if the environment is subsequently changed (including in a pre_exec hook). This avoids duplicating the Command logic.

Steps / History

(Remember to update the S-tracking-* label when checking boxes.)

Unresolved Questions

None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-unimplementedStatus: The feature has not been implemented.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