e8b29de
# This is a copy of the _filedir function in bash_completion, included
e8b29de
# and (re)defined separately here because some versions of Adobe Reader,
e8b29de
# if installed, are known to override this function with an incompatible
e8b29de
# version, causing various problems.
e8b29de
#
e8b29de
# https://bugzilla.redhat.com/677446
e8b29de
# http://forums.adobe.com/thread/745833
e8b29de
e8b29de
_filedir()
e8b29de
{
e8b29de
    local i IFS=$'\n' xspec
e8b29de
e8b29de
    _tilde "$cur" || return 0
e8b29de
e8b29de
    local -a toks
e8b29de
    local quoted tmp
e8b29de
e8b29de
    _quote_readline_by_ref "$cur" quoted
e8b29de
    toks=( ${toks[@]-} $(
e8b29de
        compgen -d -- "$quoted" | {
e8b29de
            while read -r tmp; do
e8b29de
                printf '%s\n' $tmp
e8b29de
            done
e8b29de
        }
e8b29de
    ))
e8b29de
e8b29de
    if [[ "$1" != -d ]]; then
e8b29de
        [[ ${BASH_VERSINFO[0]} -ge 4 ]] && \
e8b29de
            xspec=${1:+"!*.@($1|${1^^})"} || \
e8b29de
            xspec=${1:+"!*.@($1|$(printf %s $1 | tr '[:lower:]' '[:upper:]'))"}
e8b29de
        toks=( ${toks[@]-} $( compgen -f -X "$xspec" -- $quoted) )
e8b29de
    fi
e8b29de
    [ ${#toks[@]} -ne 0 ] && _compopt_o_filenames
e8b29de
e8b29de
    COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" )
e8b29de
}