title: Bash how to detect missing mandatory arguments passed to a script
body: <p>I have a Bash script and I need to pass a certain number of arguments to make it work.<br><br>
  <code>./upload.sh $ARG1 $ARG2 $ARG3</code><br><br>
  Let's say that the 2 mandatory fields are ARG1 and ARG2, and<br>
  ARG1 and 3 are not empty.<br></p>
  
  <p>I think the script will run and think that it has the 2 mandatory arguments, 
  Is there a way to detect that ARG2 is missing/empty? 
  I need to return exit 1 and not exit 0.</p>
  
  <p>Here's a bit of the script</p>
  
  <pre><code>RESOURCE=$1
  CONTAINER=$2
  APP_NAME=$3
  
  if [[ -z $RESOURCE || -z $CONTAINER ]];
  then
      echo `date`" - Missing mandatory arguments: resource and container. "
      echo `date`" - Usage: ./upload.sh  [resource] [container] [appname] . "
      exit 1
  fi
  </code></pre>
  
  <p>Thanks in advance,</p>
  
  <p>Alain</p>