title: Reading multiple lines in bash without spawning a new subshell?
body: <p>I'm trying to do something like</p>
  
  <pre><code>var=0  
  grep "foo" bar | while read line; do  
     var=1  
  done
  </code></pre>
  
  <p>Unfortunately this doesn't work since the pipe causes the while to run in a subshell. Is there a better way to do this? I don't need to use "read" if there's another solution. </p>
  
  <p>I've looked at <a href="https://stackoverflow.com/questions/124167/bash-variable-scope">Bash variable scope</a> which is similar, but I couldn't get anything that worked from it. </p>