Blame SOURCES/bash-completion-2.0-redefine_filedir.bash

f77742
# This is a copy of the _filedir function in bash_completion, included
f77742
# and (re)defined separately here because some versions of Adobe
f77742
# Reader, if installed, are known to override this function with an
f77742
# incompatible version, causing various problems.
f77742
#
f77742
# https://bugzilla.redhat.com/677446
f77742
# http://forums.adobe.com/thread/745833
f77742
f77742
_filedir()
f77742
{
f77742
    local i IFS=$'\n' xspec
f77742
f77742
    _tilde "$cur" || return 0
f77742
f77742
    local -a toks
f77742
    local quoted x tmp
f77742
f77742
    _quote_readline_by_ref "$cur" quoted
f77742
    x=$( compgen -d -- "$quoted" ) &&
f77742
    while read -r tmp; do
f77742
        toks+=( "$tmp" )
f77742
    done <<< "$x"
f77742
f77742
    if [[ "$1" != -d ]]; then
f77742
        # Munge xspec to contain uppercase version too
f77742
        # http://thread.gmane.org/gmane.comp.shells.bash.bugs/15294/focus=15306
f77742
        xspec=${1:+"!*.@($1|${1^^})"}
f77742
        x=$( compgen -f -X "$xspec" -- $quoted ) &&
f77742
        while read -r tmp; do
f77742
            toks+=( "$tmp" )
f77742
        done <<< "$x"
f77742
    fi
f77742
f77742
    # If the filter failed to produce anything, try without it if configured to
f77742
    [[ -n ${COMP_FILEDIR_FALLBACK:-} && \
f77742
        -n "$1" && "$1" != -d && ${#toks[@]} -lt 1 ]] && \
f77742
        x=$( compgen -f -- $quoted ) &&
f77742
        while read -r tmp; do
f77742
            toks+=( "$tmp" )
f77742
        done <<< "$x"
f77742
f77742
f77742
    if [[ ${#toks[@]} -ne 0 ]]; then
f77742
        # 2>/dev/null for direct invocation, e.g. in the _filedir unit test
f77742
        compopt -o filenames 2>/dev/null
f77742
        COMPREPLY+=( "${toks[@]}" )
f77742
    fi
f77742
} # _filedir()