title: Bash getopts multiple flags with single required parameter
body: <p>I'm having trouble wrapping my head around how to make getopts accept multiple flags with a single argument. For example.</p>
  
  <p>Flags: Children: a - Adam  b - Beth c - Cathy d - Duncan</p>
  
  <p>Required parameter: ice cream flavor</p>
  
  <p>(not what my script really does, but easiest to spell out this way)</p>
  
  <p>What I can do right now:</p>
  
  <pre><code>./flavor -a chocolate
  
  ./flavor -c chocolate 
  </code></pre>
  
  <p>What I'd like to do:</p>
  
  <pre><code>./flavor -acd chocolate
  </code></pre>
  
  <p>Rather than the only thing I can get it to do so far:</p>
  
  <pre><code>./flavor -a chocolate -c chocolate -d chocolate
  </code></pre>
  
  <p>Every variation I've tried with getopts either doesn't see the parameter at all or requires it after every single flag declaration. I feel like I'm missing something obvious that will give me the "aha" moment, but I'm not seeing it on my own. Can anyone point me in the right direction?</p>
  
  <p>============================================</p>
  
  <pre><code>while getopts ":a:b:c:d:" opt; do
    case $opt in
          a)
            do stuff with $OPTARG
           ;;
          b) 
            do stuff with $OPTARG
           ;;
          c)
            do stuff with $OPTARG
           ;;
          d)
            do stuff with $OPTARG
           ;;
          :)
           echo "Option -$OPTARG requires an argument." &gt;&amp;2
           exit 1
           ;;
    esac
  done
  </code></pre>
  
  <p>============================================</p>
  
  <p>My apologies if this is a really dumb question and thank you for your time.</p>