Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Efficient way to map a list of values to multiple processes, then accumulate their output

Wow.  I'm genuinely impressed, it even supports all of the flags that I need!  And has all of the fun non-determinism of parallel execution (with -P)!  This satisfies about 60% of what I need, and is a great tool to have handy!

The limitation appears to be that the command is run in a sub-shell / separate process (as one might expect), so there's no way to correlate input74 → output74.

I suppose with "zargs -n1" I can redirect the output of each to an individual file (in an e.g. temporary file), and then just read them back and stick everything into an associative array.

A very simple test works exactly correct, but a slight variation gives me "zargs: argument list too long":

Uploaded the source here for ease of viewing and syntax highlighting: https://gist.github.com/zachriggle/b53b35faa5a60b674575e1dc6cae1d2e

Zach Riggle

On Sat, Nov 6, 2021 at 11:18 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
On Sat, Nov 6, 2021 at 6:41 AM Zach Riggle <zachriggle@xxxxxxxxx> wrote:
> Ultimately, I'd like to have some quasi-implementation of xargs -P in pure zsh -- which maps a __function__ to a list of arguments

Look at "zargs" in "man zshcontrib"

Messages sorted by: Reverse Date, Date, Thread, Author