title: bash function check previous result
body: <p>In bash s there a way to create a flow of function that will prevent next function call if there is an error:</p>
  
  <p>i.e.</p>
  
  <pre><code>function msg_ok {
        echo "$(date '+%Y%m%d_%H%M%S'): OK+: $1 $2" | tee -a "/tmp/log_me"
  }
  function msg_er {
        echo "$(date '+%Y%m%d_%H%M%S'): ERR: $1 $2" | tee -a "/tmp/log_me"
  }
  function msg_check {
       tail last_line_of_log | grep "ERR"
       exit 
  }
  
  function first {
         msg_check
         do_your_thing
         msg_er "nothing works"
         else
         msg_ok "go on to next"
  }
  
  function second {
         msg_check
         do_your_thing
         msg_er "nothing works 2"
         else
         msg_ok "go on to next 2"
  }
  
  
  first
  second
  third
  </code></pre>
  
  <p>I mean is there a way to call first second and third in different order and stop if previously there was msg_er called ?</p>