title: How to check if gcc has failed, returned a warning, or succeeded in Bash?
body: <p>How would I go about checking whether gcc has succeeded in compiling a program, failed, or succeeded but with a warning?</p>
  
  <pre><code>#!/bin/sh
  
  string=$(gcc helloworld.c -o helloworld)
  
  if [ string -n ]; then
      echo "Failure"
  else
      echo "Success!"
  fi
  </code></pre>
  
  <p>This only checks whether it has succeeded or (failed or compiled with warnings).</p>
  
  <p>-n means "is not null".</p>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT</strong> If it's not clear, this isn't working.</p>