This is a sort of branch from this question (specifically avoiding the race condition pointed out by jmb): How can I send the stdout of one process to multiple processes using (preferably unnamed) pipes in Unix (or Windows)?
I want to execute a process in such a way that its output is displayed on the screen plus piped to a second process, but that my terminal is not released until both processes are complete. For example, if I had:
foo.sh | tee >(bar.sh)
> <--terminal released after bar (total time 5s)
>BARFOOBAR <--terminal released after foo in ~0s, before bar.sh returns at 5s
foo.sh | bar.sh