title: My option parsing snippet
body: <p>Here's a snippet that I use to parse options in Bash:</p>
  
  <pre><code>#!/bin/bash
  
  PROGNAME=${0##*/}
  PROGVERSION=0.1
  wW='-4.5.5-double'
  reName=
  
  usage()
  {
    cat &lt;&lt; EO
  Script purpose goes here.
  EO
  
    cat &lt;&lt;EO | column -s\&amp; -t
  
    -h, --help &amp; show this output
    -r, --rename &amp; renames confout to Your gro
    -v, --version &amp; show version information
    -w, --workWith &amp; gromax exec suffix
  EO
  }
  
  SHORTOPTS="hvw:r"
  LONGOPTS="help,version,workWith:rename"
  
  ARGS=$(getopt -s bash --options $SHORTOPTS --longoptions $LONGOPTS --name $PROGNAME -- "$@")
  
  eval set -- "$ARGS"
  
  while true; do
      case $1 in
          -h|--help)
              usage; exit 0;;
          -v|--version)
              echo "$PROGVERSION"; exit 0;;
          -w|--workWith)
              wW=$2; shift;;
          -r|--rename)
              reName="true"; shift;;
          --)
              shift; break;;
          *)
              shift; break;;
      esac
      shift
  done
  
  
  # ====================
  ## finally the script:
  
  echo "rename:" $reName
  echo '    wW:' $wW
  </code></pre>
  
  <p>This snippet parses option (-w) only if it is before the trigger (-r):</p>
  
  <pre><code>~/wrk/mlDn/vas/res/bbst: test.bash -w 'dfdff' -r
  rename: true
      wW: dfdff
  ~/wrk/mlDn/vas/res/bbst: test.bash -r -w 'dfdff' 
  rename: true
      wW: -4.5.5-double
  </code></pre>
  
  <p>How can this be fixed? What is wrong with my snippet?</p>