Skip to content

getopts case does not check glob-pattern #3234

@A4-Tacks

Description

@A4-Tacks
#!/usr/bin/bash
OPTIND=1
while getopts h012 opt; do case "$opt" in
    [0-9]) ;;
    :|\?)
        ((--OPTIND <= 0)) && OPTIND=1
        printf '%q: parse args failed, near by %q\n' "$0" "${!OPTIND}" >&2
        exit 2
esac done

Current shellcheck output:

Expected shellcheck output (0|1|2) ;;):

In - line 3:
while getopts h012 opt; do case "$opt" in
                           ^-- SC2213 (warning): getopts specified -h, but it's not handled by this 'case'.

For more information:
  https://www.shellcheck.net/wiki/SC2213 -- getopts specified -h, but it's no...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions