They work fine and do what they need (print the contents of the foo file):
cat <foo while read line; do echo $line; done <foo cat <(cat foo)
However, this gives me a syntax error in zsh:
zsh$ while read line; do echo $line; done <(cat foo) zsh: parse error near `<(cat foo)'
and bash:
bash$ while read line; do echo $line; done <(cat foo) bash: syntax error near unexpected token `<(cat foo)'
Does anyone know the reason and possibly the workaround?
Note. This is obviously a toy example. In real code, I need the body of the while loop to execute in the main shell process, so I cannot just use
cat foo | while read line; do echo $line; done
source share