4
  	   ˆÀÄ0¿Â  	   ˆÀÄ0¿Â  	   ˆÀÄ0¿Â  #   ˆl–ß=¿J *j"TíÀ3q¦”Å£Å„Z}ÏÀÃ ,è    # bash completion for yum

_yum_helper()
{
    local IFS=$'\n'
    if [[ -n "$YUM_CACHEDIR" && "$1 $2" == "list available" ]]; then
        for db in $(find "$YUM_CACHEDIR" -name primary_db.sqlite); do
            COMPREPLY+=( $( sqlite3 "$db" \
                "SELECT name||'.'||arch FROM packages WHERE name LIKE '$3%'"
            ) )
        done
        return
    fi
    COMPREPLY+=( $(
        /usr/share/yum-cli/completion-helper.py -d 0 -C "$@" 2>/dev/null ) )
}

_yum_list()
{
    # Fail fast for things that look like paths or options.
    [[ $2 == */* || $2 == [.~-]* ]] && return
    # Listing all available packages takes way too long
    [[ $1 != "installed" && ${#2} -lt 1 ]] && return
    _yum_helper list "$@"
}

# arguments:
#   1 = 1 or 0 to list enabled or disabled plugins
#   2 = current word to be completed
_yum_plugins()
{
    local val
    [[ $1 -eq 1 ]] && val='\(1\|yes\|true\|on\)' || val='\(0\|no\|false\|off\)'
    COMPREPLY+=( $( compgen -W '$( command grep -il "^\s*enabled\s*=\s*$val" \
        /etc/yum/pluginconf.d/*.conf 2>/dev/null \
        | sed -ne "s|^.*/\([^/]\{1,\}\)\.conf$|\1|p" )' -- "$2" ) )
}

# arguments:
#   1 = current word to be completed
_yum_binrpmfiles()
{
    COMPREPLY+=( $( compgen -f -o plusdirs -X '!*.rpm' -- "$1" ) )
    COMPREPLY=( $( compgen -W '"${COMPREPLY[@]}"' -X '*.src.rpm' ) )
    COMPREPLY=( $( compgen -W '"${COMPREPLY[@]}"' -X '*.nosrc.rpm' ) )
}

_yum_baseopts()
{
    local opts='--help --tolerant --cacheonly --config --randomwait
        --debuglevel --showduplicates --errorlevel --rpmverbosity --quiet
        --verbose --assumeyes --assumeno --version --installroot --enablerepo
        --disablerepo --exclude --disableexcludes --obsoletes --noplugins
        --nogpgcheck --skip-broken --color --releasever --setopt --downloadonly
        --downloaddir --disableincludes'
    [[ $COMP_LINE == *--noplugins* ]] || \
        opts+=" --disableplugin --enableplugin"
    printf %s "$opts"
}

_yum_transactions()
{
    COMPREPLY+=( $( compgen -W "$( $yum -d 0 -C history 2>/dev/null | \
        sed -ne 's/^[[:space:]]*\([0-9]\{1,\}\).*/\1/p' )" -- "$cur" ) )
}

_yum_atgroups()
{
    if [[ $1 == \@* ]]; then
        _yum_helper groups list all "${1:1}"
        COMPREPLY=( "${COMPREPLY[@]/#/@}" )
        return 0
    fi
    return 1
}

# arguments:
#   1 = current word to be completed
#   2 = previous word
# return 0 if no more completions should be sought, 1 otherwise
_yum_complete_baseopts()
{
    case $2 in

        -d|--debuglevel|-e|--errorlevel)
            COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9 10' -- "$1" ) )
            return 0
            ;;

        --rpmverbosity)
            COMPREPLY=( $( compgen -W 'info critical emergency error warn
                debug' -- "$1" ) )
            return 0
            ;;

        -c|--config)
            COMPREPLY=( $( compgen -f -o plusdirs -X "!*.conf" -- "$1" ) )
            return 0
            ;;

        --installroot|--downloaddir)
            COMPREPLY=( $( compgen -d -- "$1" ) )
            return 0
            ;;

        --enablerepo)
            _yum_helper repolist disabled "$1"
            return 0
            ;;

        --disablerepo)
            _yum_helper repolist enabled "$1"
            return 0
            ;;

        --disableexcludes|--disableincludes)
            _yum_helper repolist all "$1"
            local main=
            [[ $2 == *excludes ]] && main=main
            COMPREPLY=( $( compgen -W '${COMPREPLY[@]} all $main' -- "$1" ) )
            return 0
            ;;

        --enableplugin)
            _yum_plugins 0 "$1"
            return 0
            ;;

        --disableplugin)
            _yum_plugins 1 "$1"
            return 0
            ;;

        --color)
            COMPREPLY=( $( compgen -W 'always auto never' -- "$1" ) )
            return 0
            ;;

        -R|--randomwait|-x|--exclude|-h|--help|--version|--releasever|--cve|\
        --bz|--advisory|--tmprepo