Why can't `std::process::Command` implement `Clone`?

Why can't std::process::Command implement Clone?

2 Likes

It wouldn't be able to clone certain types of data like pre_exec closures.

3 Likes

If so, would an inherent .clone() method that ignores the closure thing be a good idea? I sometimes find myself wanting to copy and edit a preexisting Command. Having a way to deduplicate adding the same arguments of a Command is nice.

1 Like

The common approach I have seen is to just define a function creating the "base" command, then call it and chain on additional modifications for each usage.

8 Likes