bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: anonymous pipes in recursive function calls


From: konsolebox
Subject: Re: anonymous pipes in recursive function calls
Date: Mon, 1 Jul 2024 17:06:20 +0800

On Sun, Jun 30, 2024 at 5:50 AM Zachary Santer <zsanter@gmail.com> wrote:
> > > Filling an array of paths and then looping over it in a subsequent for
> > > loop wouldn't actually be unreasonable here, considering how many
> > > paths there are. It just feels like bad practice.
> >
> > Why do you think it's a bad practice?
>
> Some of the power of bash is the ease with which it enables
> parallelism. Collecting all the output from a command or block of code
> before it gets passed to the next is throwing away that benefit.
> Additionally, you might find yourself with so much output that it's
> too much to expand all at once in the for loop. Don't know what that
> limit is, but you're at the very least using more memory than you
> would be otherwise.

But then you're allowing multiple processes and pipes to be open at
the same time, unnecessarily allowing more room for unexpected errors.
Isn't that worse?  It doesn't matter if bash seamlessly allows
multiple recursion-generated pipes or not.

Your use case at some point may be practical but it's the one that
should be questioned first.  Storing output is the sane choice in most
cases.




--
konsolebox



reply via email to

[Prev in Thread] Current Thread [Next in Thread]