CodexBloom - Programming Q&A Platform

Bash script fails to read from a pipe when using process substitution on macOS

👀 Views: 74 đŸ’Ŧ Answers: 1 📅 Created: 2025-09-06
bash macos process-substitution Bash

I keep running into I'm migrating some code and I'm migrating some code and Hey everyone, I'm running into an issue that's driving me crazy... I'm encountering an issue with a Bash script on macOS where I'm trying to read the output of a command through a pipe using process substitution, but it seems like the script hangs indefinitely. The specific command I'm using is `cat <(ls -l)`. When I run this, I expect to see the output of `ls -l`, but instead, the terminal just freezes. I've verified that `ls -l` works on its own. Here is a simplified version of the script I am running: ```bash #!/bin/bash output=< <(ls -l) while read -r line; do echo "Read line: $line" done < "$output" ``` I've tried replacing `<(ls -l)` with a regular file and it works as expected. Additionally, I've checked my `bash` version, which is 3.2.57 on macOS Big Sur. When I run the script, I see no output and it hangs. I also tried using `bash -x script.sh` to enable debugging, but it doesn't provide any additional insight into where it's getting stuck. Is there something about using process substitution on macOS's version of Bash that I'm missing? Any ideas on how to resolve this would be greatly appreciated. Thanks in advance! This issue appeared after updating to Bash stable. Any help would be greatly appreciated! I'm working on a CLI tool that needs to handle this. Any help would be greatly appreciated! Has anyone else encountered this?