The use of getopt in bash

-sharp!/bin/bash

ARGS=`getopt -o ab: -l "argv3:,help" -- "$@"`
eval set -- "${ARGS}"

while true;
do
    case "$1" in
        -a) 
            echo "i am a"
            shift
            ;;
        -b) 
            echo "i am b, my value is $2" 
            shift 2
            ;;
        --argv3)
            echo "i am argv3, my value is $2"
            shift 2
            ;;
        --help)
            echo "i am help info"
            exit 0
            ;;
        --)
            shift
            break
            ;;
        *)
            echo "Internal error!"
            exit 1
            ;;
    esac
done

the above file is saved as test.sh
1.test.sh, and Internal error!

will be output.
  1. -- "$@"

$@ represents all the parameter lists.
what does the "$@" here mean?

ARGS=`getopt -o ab: -l "argv3:,help" -- "$@"`

rewrite ARGS= getopt-o ab:-l "argv3:,help"-"$@" to

ARGS=`getopt -o ab: -l "argv3:,help" ` 

Mar.18,2021
Menu