-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.In the final comment period and will be merged soon unless new substantive objections are raised.
Description
You can add a vector of command-line arguments to a Command object with .args()
, but there's no equivalent for environment variables. I'd like to be able to do things like
let filtered_env : Vec<(String, String)> =
std::env::vars().filter(|&(ref k, ref v)| /* criterion */).collect();
let status = Command::new("printenv")
.stdin(Stdio::null())
.stdout(Stdio::inherit())
.env_clear()
.envs(filtered_env)
.status();
Right now I have to do instead
let mut cmd = Command::new("printenv");
cmd.stdin(Stdio::null());
cmd.stdout(Stdio::inherit());
cmd.env_clear();
for (ref k, ref v) in filtered_env {
cmd.env(k, v);
}
let status = cmd.status();
which breaks the builder pattern and extends the scope of the Command object.
Metadata
Metadata
Assignees
Labels
B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.In the final comment period and will be merged soon unless new substantive objections are raised.