0

Having a bit of trouble here. I haven't had to do long options ever, so I am trying getopt rather than getopts.

For some reason it keeps stating shift as an unrecognized token. Any reason why? Also is this a proper implementation for getopt? Or is there a better method for this?

BASH SCRIPT BELOW:

FLAGS=$(getopt --long "help,user:" --name $PROGNAME -- "$@")
echo $FLAGS
eval set -- "$FLAGS"

while true; do
  case $1 in
    --help)
        usage()
        shift
        ;;
    *)
      shift
      exit 1
      ;;
  esac
  shift
done
Kyle Calica-St
  • 2,629
  • 4
  • 26
  • 56

1 Answers1

3

In Bash you don't call functions with brackets - usage() should instead be usage.

l0b0
  • 55,365
  • 30
  • 138
  • 223