#!/bin/bash
# ref: https://shellscript.sunone.me/parameter.html

CMDNAME=`basename $0`

while getopts ab:c: OPT
do
  case $OPT in
    "a" ) FLG_A="TRUE" ;;
    "b" ) FLG_B="TRUE" ; VALUE_B="$OPTARG" ;;
    "c" ) FLG_C="TRUE" ; VALUE_C="$OPTARG" ;;
    * ) echo "Usage: $CMDNAME [-a] [-b VALUE] [-c VALUE]" 1>&2
      exit 1 ;;
  esac
done

if [ "$FLG_A" = "TRUE" ]; then
  echo 'pass a flag'
fi

if [ "$FLG_B" = "TRUE" ]; then
  echo 'pass b flag'
  echo "with value: $VALUE_B"
fi

if [ "$FLG_C" = "TRUE" ]; then
  echo 'pass c flag'
  echo "with value: $VALUE_C"
fi

exit 0

{'avg_line_length': 17.96875, 'max_line_length': 62, 'alphanum_fraction': 0.568695652173913, 'licenses': ['Apache-2.0'], 'repository_name': 'atoato88/misc-scripts', 'path': 'others/get_options2.sh', 'size': 575, 'lang': 'Shell'}