title: Capture both stdout and stderr in Bash
body: <p>I know this syntax</p>
  
  <pre><code>var=`myscript.sh`
  </code></pre>
  
  <p>or</p>
  
  <pre><code>var=$(myscript.sh)
  </code></pre>
  
  <p>Will capture the result (<code>stdout</code>) of <code>myscript.sh</code> into <code>var</code>. I could redirect <code>stderr</code> into <code>stdout</code> if I wanted to capture both.  How to save each of them to separate variables?</p>
  
  <p>My use case here is if the return code is nonzero I want to echo <code>stderr</code> and suppress otherwise.  There may be other ways to do this but this approach seems it will work, if it's actually possible.</p>