title: How to ignore invalid arguments with getopts and continue parsing?
body: <p>I've the following simple code:</p>
  
  <pre><code>#!/usr/bin/env bash
  while getopts :f arg; do
    case $arg in
      f) echo Option $arg specified. ;;
      *) echo Unknown option: $OPTARG. ;;
    esac
  done
  </code></pre>
  
  <p>and it works in simple scenarios such as:</p>
  
  <pre><code>$ ./test.sh -f
  Option f specified.
  $ ./test.sh -a -f
  Unknown option: a.
  Option f specified.
  </code></pre>
  
  <p>However it doesn't work for the following:</p>
  
  <pre><code>$ ./test.sh foo -f
  
  $ ./test.sh -a abc -f
  Unknown option: a.
  </code></pre>
  
  <p>How do I fix above code example to support invalid arguments?</p>