Syntaxe typique :

opts=$(getopt --name "$0" --options 'h:[...]' [-l ...]... -- "$@")

if [ $? -ne 0 ]
then
    echo "$0: error during argument parsing" >&2
    exit 1
fi

eval set -- "$opts"
unset opts

while true
do
    case "$1" in
        '-h'|'--help')
            [...]
            ;;
        [...]
        '--')
            break
            ;;
        *)
            echo "$0: error during argument processing" >&2
            exit 1
            ;;
    esac
done

Emacs 30.0.50 (Org mode 9.6.15)