title: getopts empty argument and default value
body: <p>my requirement is really simple, I just want to check that if the <code>getopts</code> argument is empty or not. I am kicking my script using the jenkins and need to check that if the provided value is empty then set the default otherwise use the provided value:
  <a href="https://i.stack.imgur.com/ZAer7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZAer7.jpg" alt="enter image description here"></a></p>
  
  <p>and passing the arguments to the shell script like this:</p>
  
  <pre><code>./rds-db-dump.sh -s ${source_instance_id}  -c ${target_instance_class} -i ${source_snapshot_id}
  </code></pre>
  
  <p>snippet from shell script:</p>
  
  <pre><code>while getopts ":s:c:i:h" opt; do
    case ${opt} in
      s) SOURCE_INSTANCE_ID="${OPTARG}"
      ;;
      c) TARGET_INSTANCE_CLASS="${OPTARG}"
      ;;
      i) SOURCE_SNAPSHOT_ID="${OPTARG}"
      ;;
      h) usage &amp;&amp; exit 1
      ;;
      \?) echo "Invalid option -${OPTARG}" &gt;&amp;2
      usage &amp;&amp; exit 1
      ;;
    esac
  done
  
  echo "SOURCE_SNAPSHOT_ID: ${SOURCE_SNAPSHOT_ID}"
  echo "TARGET_INSTANCE_CLASS: ${TARGET_INSTANCE_CLASS}"
  </code></pre>
  
  <p>when I kicked off this job, it doesn't give me desired result:
  <a href="https://i.stack.imgur.com/sCV8o.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sCV8o.jpg" alt="enter image description here"></a>  </p>
  
  <p>How I can achieve that with <code>getopts</code> to check if the argument is empty than assign some default value of perform some operation otherwise use the provided value of argument.</p>