Using `tee` with file descriptors in a subshell causes advanced patterns in Bash 5.1
I've searched everywhere and can't find a clear answer. I'm relatively new to this, so bear with me. I'm working with unexpected behavior when trying to use `tee` with file descriptors in a subshell in Bash 5.1. I'm attempting to log output from a command while also processing it in a pipeline, but the logging isn't happening as expected. Here's the simplified version of my command: ```bash ( echo "Hello World" | tee /dev/stderr | grep "World" ) > output.log ``` What I expect is for `output.log` to contain the filtered output 'Hello World', while also printing it to standard behavior. However, I only see 'Hello World' in the terminal but nothing in `output.log`. I’ve tried changing the order of the commands and redirecting output, but nothing seems to resolve this scenario. I also checked that the `output.log` file is being created; however, it remains empty after execution. When running without the subshell (i.e., without the parentheses), it behaves correctly. This behavior seems tied to how subshells handle file descriptors in Bash 5.1, but I haven't found much documentation on this specific case. Is there a workaround or a different approach I can take to ensure that both the logging and the piped processing work as intended? I'd really appreciate any guidance on this. This is for a microservice running on Ubuntu 22.04. Thanks in advance! What are your experiences with this?