title: why process substitution does not always work with while loop in bash?
body: <p>The <a href="http://www.gnu.org/software/bash/manual/bash.html#Process-Substitution" rel="noreferrer">process substitution</a> works with filenames fine, e.g. both</p>
  
  <pre><code>$ cat &lt;FILENAME</code></pre>
  
  <p>and</p>
  
  <pre><code>$ while read i; do echo $i; done &lt;FILENAME</code></pre>
  
  <p>work.</p>
  
  <p>But if instead of FILENAME we use <code>echo</code> command (or any other, which generates output to stdout), <code>cat</code> continues to work</p>
  
  <pre><code>$ cat &lt;(echo XXX)
  XXX</code></pre>
  
  <p>while the loop</p>
  
  <pre><code>$ while read i; do echo $i; done &lt;(echo XXX) 
  bash: syntax error near unexpected token `&lt;(echo XXX)'
  </code></pre>
  
  <p>produces error.</p>
  
  <p>Any ideas why?</p>