title: bash script using && not stopping on error
body: <p>i have a script that I accidentally ran without an underlying file present, and my script doesn't have a check for this file, because the script should stop when the command that requires that file exits <code>1</code>.</p>
  
  <p>i got caught out because it went ahead and skipped the <code>sleep</code> command and the <code>||exit 0</code> <code>if</code> test that I have as some protection protection. i would really like to know why. the if test and exit works if the preceding command doesn't fail.</p>
  
  <p>if i strip the script down I can see some unexpected behaviour where the script doesn't stop at the <code>&amp;&amp;</code> and skips the next <code>sleep</code> command.</p>
  
  <p>is this not the correct way to use <code>&amp;&amp;</code>? </p>
  
  <p>you can test this here:</p>
  
  <pre><code>#!/bin/bash
  mkdir /root/simulatecomplexcommandthatreturns1 &amp;&amp;
  sleep 5m
  echo "let's go ahead and delete all the stuff"
  find /blah/ -delete
  </code></pre>
  
  <p>this is on debian 9</p>
  
  <p>EDIT:</p>
  
  <p>for clarity, I want the script to stop when it encounters an error and I have <code>&amp;&amp;</code>. I just thought it was odd that it didn't run the <code>sleep</code> command.</p>