title: In a bash function, how do I get stdin into a variable
body: <p>I want to call a function with a pipe, and read all of stdin into a variable.</p>
  
  <p>I read that the correct way to do that is with <code>read</code>, or maybe <code>read -r</code> or <code>read -a</code>. However, I had a lot of problems in practise doing that (esp with multi-line strings).</p>
  
  <p>In the end I settled on</p>
  
  <pre><code>function example () {
    local input=$(cat)
    ...
  }
  </code></pre>
  
  <h2>What is the idiomatic way to do this?</h2>