On Sat, Jun 13, 2026 at 05:58:58 +0200, Borden via wrote:
> I'm trying to figure out the mechanics of process substitution fromÂ
>https://www.gnu.org/software/bash/manual/html_node/Process-Substitution.htmlÂ
> and the rest of the Internet.
> The bash manual doesn't need a lengthy explanation on asynchronous IO. It
> would be sufficient to explain the differences named pipes have from stream
> redirectors, generally explain how named pipes can be read and written, and
> what users should search for in their foundational research.
The guidance you're looking for is more appropriate for a book or a
tutorial, rather than official documentation, I believe.
Process substitutions work very much like anonymous pipes. Two or more
programs are running concurrently, and input may be available or
unavailable based on whether it has already been written.
Consider a basic pipeline like this:
slowwriter() { while sleep 1; do echo "$RANDOM"; done; }
eagerreader() { local REPLY; while read -r; do echo "Next: $REPLY"; done; }
slowwriter | eagerreader
If you run this, you'll see a line of output every second, until you
interrupt it (e.g. with Ctrl-C).
We can do the same thing with a process substitution:
eagerreader < <(slowwriter)
Once again, we see a line of output every second, until the commands are
interrupted.
So, what's the difference? In this case, there is no real difference
other than the way we would check exit codes, if we cared about those.
But let's take a different example:
printf '%s\n' {1..10} | readarray -t numbers # bash 4.0 or later
This has no visible effect, because the readarray command takes place
in a subshell. The numbers array is populated, but that happens in
a subshell, and the resulting array is lost when the subshell exits.
But if we do it in a process substitution, the result is different:
readarray -t numbers < <(printf '%s\n' {1..10})
In this case, the readarray command is *not* executed in a subshell.
It's executed by our interactive shell, and therefore the numbers array
survives. We can see it with "declare -p numbers" (among others).
This is the primary use of process substitutions in most scripts.
There are of course many other uses, but I'm not going to try to list
them all here.
If you have more specific questions, feel free to ask.