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