title: Bash variable from subshell not storing return value from grep
body: <p>I have the following line of code in a bash script:</p>
  
  <pre><code># Is there an external monitor connected via HDMI?
  has_external=$(xrandr 2&gt; /dev/null | grep -q 'HDMI[0-9] connected')
  </code></pre>
  
  <p>The output of <code>xrandr</code> could contain this:</p>
  
  <pre><code>HDMI1 connected (normal left inverted right x axis y axis)
  HDMI2 disconnected (normal left inverted right x axis y axis)
  HDMI3 disconnected (normal left inverted right x axis y axis)
  </code></pre>
  
  <p>For the life of my I can't figure out why the <code>has_external</code> variable always evaluates to true, even if "HDMI1 connected" is not in the output of <code>xrandr</code>. Any ideas?</p>