Skip to content

error pairs matching in bash script #111

@Kaiser-Yang

Description

@Kaiser-Yang

for example:

    while [[ $# -gt 0 ]]; do
        case "$1" in
            --restore)
                RESTORE=true
                shift
                ;;
            --help)
                usage
                return 1
                ;;
            --verbose)
                VERBOSE=true
                shift
                ;;
            --install)
                INSTALL_PACKAGES=true
                shift
                ;;
            --create)
                CREATE_LINKS=true
                shift
                ;;
            --extract)
                EXTRACT=true
                shift
                ;;
            --fonts)
                INSTALL_FONTS=true
                shift
                ;;
            --change)
                CHANGE_SHELL=true
                shift
                ;;
            -*)
                short_opts="${1:1}"
                for ((i=0; i<${#short_opts}; i++)); do
                    case "${short_opts:$i:1}" in
                        r) RESTORE=true ;;
                        h) usage; return 1 ;;
                        v) VERBOSE=true ;;
                        i) INSTALL_PACKAGES=true ;;
                        c) CREATE_LINKS=true ;;
                        e) EXTRACT=true ;;
                        f) INSTALL_FONTS=true ;;
                        s) CHANGE_SHELL=true ;;
                        *) log_erro "Unknown option: -${short_opts:$i:1}"; usage; return 1 ;;
                    esac
                done
                shift
                ;;
            *)
                log_erro "Unknown option: $1"
                usage
                return 1
                ;;
        esac
    done

This is very similar for bash scripting needed to handle the options.

This plugin should ignore the mismatch in the switch case of bash (maybe including other POSIX shell scripts language), which is leagal for them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions