When designing a chain of commands to perform a certain task, i ran into the problem that anonymous pipes do not behave like expected. As the original command that i am running is too complex to explain here, i've created an example that shows the problem (i know that all these commands are doing basically nothing). Also, i am using pv to show whether the data is actually copied from input to output.
cat /dev/zero | pv > /dev/null
This works as expected. (copy data from /dev/zero to /dev/null)
cat /dev/zero | tee /dev/null | pv > /dev/null
This also works as expected (duplicate the data and send both copies to /dev/null)
cat /dev/zero | tee >(pv -c > /dev/null) | pv -c > /dev/null
This command only partially works. While the copy from STDIN to STDOUT still works, (one pv will show progress for a short time), the whole command gets stalled by the anonymous pipe, which does not receive anything and thus tee stalls as one of the outputs cannot be written to (I checked this by letting it write to files instead of /dev/null).
If anyone has an Idea why this does not work (as expected ?) in bash, i'd be glad for the help.
PS: If I use zsh instead of bash, the command runs as expected. Unfortunately, the system this needs to run on has no zsh and there is no way for me to get zsh on that system deployed.