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