rust-lang / rust-lang/rfcs

Add a method to reset the arguments to `std::process::Command`

Open
#3,227 6 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

T-libs
Dominant language
Markdown
Stars
6.6k
Forks
1.7k
Avg merge
16h 14m
Merged PRs (30d)
1

Description

std::process::Command docs

It would be cool if this struct has an option to reset all the current arguments, this would be useful fo example here:

use std::{
    io::Result,
    process::{Child, Command},
};

pub fn get_killer() -> Box<dyn FnMut(&str) -> Result<Child>> {
    let is_windows = cfg!(target_os = "windows");

    let mut cmd = Command::new(if is_windows { "cmd" } else { "pkill" });

    Box::new(move |program| {
        cmd.reset_args(); // removing previous args from previous closure calls

        if is_windows {
            cmd.args(["taskkill", "/IM", program, "/F"]);
        } else {
            cmd.arg(program);
        }

        cmd.spawn()
    })
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked std::process::Command documentation and the example in this issue to understand the requested argument-reset behavior. Done means reaching agreement on the API and its semantics for removing previously added arguments; no implementation files or tests are named in the payload.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.