title: How do I keep empty lines while reading a command into a bash array?
body: <p>I'm using bash to create a script outputting a set of values (one per line), then run it, and then put the output into an array. I want to retain the empty lines as empty array elements, because an empty value is still a value and it's the only way to match up to the list of values I was expecting back.</p>
  
  <p>So for the following bash code:</p>
  
  <pre><code>&gt; IFS=$'\n'
  &gt; foo=( $(echo 'foo bar'; echo; echo; echo baz) )
  &gt; echo ${#foo[@]}
  2
  </code></pre>
  
  <p>I expected to see 4 output, because there were four lines of output. Instead only the lines with something on them are included, so there are only two values in the array.</p>
  
  <p>The following alternatives didn't help:</p>
  
  <pre><code>&gt; foo=( `echo 'foo bar'; echo; echo; echo baz` )
  &gt; echo ${#foo[@]}
  2
  &gt; foo=( "$(echo 'foo bar'; echo; echo; echo baz)" )
  &gt; echo ${#foo[@]}
  1
  </code></pre>
  
  <p>How can this be done?</p>