title: Bash conditional based on exit code of command
body: <p>In Bash, I would like an if statement which is based of the exit code of running a command. For example:</p>
  
  <pre><code>#!/bin/bash
  
  if [ ./success.sh ]; then
      echo "First: success!"
  else
      echo "First: failure!"
  fi
  
  if [ ./failure.sh ]; then
      echo "Second: success!"
  else
      echo "Second: failure!"
  fi
  </code></pre>
  
  <p><strong>success.sh</strong></p>
  
  <pre><code>#!/bin/bash
  
  exit 0
  </code></pre>
  
  <p><strong>failure.sh</strong></p>
  
  <pre><code>#!/bin/bash
  
  exit 1
  </code></pre>
  
  <p>This should print out:</p>
  
  <pre><code>First: success!
  Second: failure!
  </code></pre>
  
  <p>How would I achieve this? Thanks!</p>