On Mon, 2024-03-11 at 15:36 -0400, Greg Wooledge wrote: > You won't be able to take advantage of "wait -n"'s ability to react > to the first job that finishes. You'll end up reaping each job in > the order they started, not the order they finished.
It feels to me like you're trying to reproduce make's already-available parallel build support, in a kind of kludgy way with bash. Maybe this is an XY problem and you should step back and describe WHY you're trying to create this behavior using bash instead of just using make's support for parallel jobs. What about make's parallel jobs doesn't meet your requirements (or put another way, what actually are your requirements)?