Add Cmd::before_spawn
to allow modifying the resulting std::process::Command
before spawning it
#81
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey! I've been using this crate a bunch and it's been great!
For one of my use cases I need to run a process under a different uid. If I want to do this I can use xshell to build the command then I need to eject out and convert it directly to
std::process::Command
to set the uid. If I do that, though, I can no longer useread
and I end up needing to write a bunch of code to replicate it.Adding a
uid
method felt too platform-specific so this PR instead adds abefore_spawn
method that registers a function that gets called with thestd::process::Command
just before it is spawned. It is based on thebefore_spawn
method in duct which does the exact same thing.Notes
CmdData
needs to beClone + Send + Sync
andBox<dyn Fn(&mut Command)>
is none of those so I ended having to place the list of methods directly inCmd
.'a
but that broke one of the tests so I've left the hook asBox<dyn Fn(&mut Command) + 'static>
instead.Cmd
tostd::process::Command
since they are fallible. I have documented this in the method documentation.