title: difference between "exec" and "exit" in bash
body: <p>I have seen both "exit" and "exec" used in bash script to stop script execution if an error has occurred. For example:</p>
  
  <pre><code>if [ ! -f file ]; then
  echo "no file"
  exit 1
  fi
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>if [ ! -f file ]; then
  exec echo "no file"
  fi
  </code></pre>
  
  <p>What is the best practise here and why? Wider discussion/explanations regarding "exec" and "exit" are welcome as well :)</p>