title: why does $(cat) drop a newline
body: <p>foo.sh:</p>
  
  <pre><code>#!/bin/bash
  
  x="$(cat)"
  
  echo "got &gt;&gt;&gt;$x&lt;&lt;&lt;"
  </code></pre>
  
  <p>In the shell</p>
  
  <pre><code>#&gt; echo abc | foo.sh
  got &gt;&gt;&gt;abc&lt;&lt;&lt;
  </code></pre>
  
  <p>Where has the trailing newline character gone?</p>