title: Shell script not reading getopts arguments on MacOS
body: <p>I have written a script that performs tasks according to switches used on command line. Here is my script:
  Expects the git branch name and two optional switches</p>
  
  <p>-r for resetting database</p>
  
  <p>-t for merging training data</p>
  
  <p><strong>test.sh</strong></p>
  
  <pre><code>merge_training=false
  reset_database=false
  
  while getopts ":tr" opt; do
    case ${opt} in
      t ) # process option t
         echo "one"
         $merge_training=true
         ;;
      r ) # process option r
         echo "two"
         $reset_database=true
         ;;
     esac
  done
  
  echo $reset_database
  echo $merge_training
  </code></pre>
  
  <p>When I run this script with command:</p>
  
  <pre><code>sh test.sh branchname -r -t
  </code></pre>
  
  <p>It does not print <strong>one</strong> or <strong>two</strong> and the last statements prints:</p>
  
  <pre><code>false
  false
  </code></pre>
  
  <p>What is wrong here?</p>