title: How to use getopt with long options in Bash?
body: <p>I have the following code in Bash:</p>
  
  <pre><code>declare {BPM_USERNAME,BPM_PASSWORD,HOST,TARGET_IP,OVERRIDE_STATUS}=''
  OPTS=`getopt -a --longoptions username:,password:,csc:,ip:,override: -n "$0" -- "$@"`
  eval set -- "$OPTS"
  
  if [ $? != 0 ] ; then echo "Failed parsing options." &gt;&amp;2 ; exit 1 ; fi
  
  while true; do
      echo ""
      echo $OPTS
      echo $1
      echo $2
  
    case "$1" in
      --username )
          BPM_USERNAME=$2
          shift 2
          ;;
      --password )
          BPM_PASSWORD=$2
          shift 2
          ;;
      --csc )
          HOST=$2
          shift 2
          ;;
      --ip )
          TARGET_IP=$2
          shift 2
          ;;
      --override )
          OVERRIDE_STATUS=$2
          shift 2
          ;;
      --)
          shift
          echo "Breaking While loop"
          break
          ;;
      *)
          echo ""
          echo "Error in given Parameters. Undefined: "
          echo $*
          echo ""
          echo "Usage: $0 [--username BPM_USERNAME] [--password BPM_PASSWORD] [--ip IP ADDRESS_OF_VyOS/BPM] [--csc CLIENT_SHORT_CODE] [--override TRUE/FALSE]"
          exit 1
    esac
  done
  </code></pre>
  
  <p>I give Bash the following command (name of script is UpdateSSL.sh):</p>
  
  <pre><code>./UpdateSSL.sh -username bpmadmin -password bpmadmin -ip 10.91.201.99 -csc xyz -override False
  </code></pre>
  
  <p>But instead of parsing the options, I get back the following result (showing that the while loop goes to the <code>*)</code> case):</p>
  
  <pre><code>'bpmadmin' --password 'bpmadmin' --ip '10.91.201.99' --csc 'xyz' --override 'False' --
  bpmadmin
  --password
  
  Error in given Parameters. Undefined: 
  bpmadmin --password bpmadmin --ip 10.91.201.99 --csc xyz --override False --
  
  Usage: ./UpdateSSL.sh [--username BPM_USERNAME] [--password BPM_PASSWORD] [--ip IP ADDRESS_OF_VyOS/BPM] [--csc CLIENT_SHORT_CODE] [--override TRUE/FALSE]
  </code></pre>
  
  <p>I don't know what I'm doing wrong.</p>