title: Bash how to execute all commands but return exit value of previous command
body: <p>I want to test if a c++ library was successfully installed so I have a chain of commands: </p>
  
  <pre><code>$ echo '#include "library_to_check_for"' &gt; test.cpp &amp;&amp; g++ test.cpp ??? rm test.cpp ???
  </code></pre>
  
  <p>Where the remove command needs to happen every time but I need $? to return the status from the compile command (i.e. compilation was successful &amp; the library was found, or not)</p>
  
  <p>Logically, I think there's a way to AND/OR something in there to get it to work.. I just can't wrap my head around it</p>
  
  <p>possibly this..?</p>
  
  <pre><code>$ echo '#include "library_to_check_for"' &gt; test.cpp; g++ test.cpp; rm test.cpp; exit (something?)
  </code></pre>