osproc.execCmdEx
now takes an optional input
for stdin, env
, workingDir
#14211
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.
osproc.execCmdEx
now takes an optionalinput
for stdin. This is a common use case, and avoids the bashisminput | cmd
for common cases where input is small enough to avoid blocking (eg on OSX, 140_000 does not block but 150_000 blocks)as noted, writing stdin by chunks (in case of large stdin) would require selectors (kqueue/epoll etc) otherwise you'll end up blocking either when writing to stdin (pipe full) or reading from stdout (output empty). This can be fixed in future work (actually I'm advocating for a osproc2 that fixes all the design issues with osproc, but that's left as future work).
the runnableExample comment is intentionally not a doc comment but may be useful for people looking at the code (it hits
^[[0m
is inserted in stderr forecho code | nim c -
timotheecour/Nim#152 depending on your user config)the
when (NimMajor, NimMinor, NimPatch) < (1, 3, 3): doAssert input.len == 0
is a compromise for the sake of simplicity (avoiding to rewrite a separate template etc)env
,workingDir
are also added for more consistency with rest of osproc and to avoid more bashisms (eg"cd $dir && cmd"
or other existing kludges)