On Mon, Apr 10, 2017 at 06:56:30PM +0200, SZEDER Gábor wrote:
> On Mon, Apr 10, 2017 at 6:35 PM, Jeff King <[email protected]> wrote:
> > On Mon, Apr 10, 2017 at 06:31:54PM +0200, SZEDER Gábor wrote:
>
> >> This means we can write this simply as:
> >>
> >> doesnt_matter=$(git gc --auto 9>&1)
> >>
> >> It's still hackery :)
> >
> > Heh. Yeah, I would call that _more_ hackery in that it's much more
> > clever. But it is shorter. :)
> >
> > I think as long as the trickery is documented that's OK (and calling it
> > doesnt_matter and explaining in the commit message is fine by me;
> > hopefully that name would induce somebody to look in the history).
>
> For the sake of self documentation and potential future users, I will
> put it into a helper function like run_and_wait_for_detached_auto_gc()
> or something. Jury is still out on the proper function name (it would
> be a shame if the funcname were longer than the command ;), but time
> is up for today...
I wonder if you could make it a general test-lib function, like:
run_and_wait () {
# we read stdout from the child only for the side effect
# of waiting until all child sub-processes exit, closing their
# fd 9.
does_not_matter=$("$@" 9>&1)
}
You could make it even more general by doing an 'eval' in the middle,
but that is probably getting too insane. :)
I don't know if there are other spots that would benefit from this. Most
of the other racy stuff like this that I recall working on actually
wanted to run two co-processes (so background something, then keep
running the test, then ask the backgrounded task to die and wait for it
to finish).
-Peff