| 59 |
- |
1 |
# This is a copy of the _filedir function in bash_completion, included
|
|
|
2 |
# and (re)defined separately here because some versions of Adobe Reader,
|
|
|
3 |
# if installed, are known to override this function with an incompatible
|
|
|
4 |
# version, causing various problems.
|
|
|
5 |
#
|
|
|
6 |
# https://bugzilla.redhat.com/677446
|
|
|
7 |
# http://forums.adobe.com/thread/745833
|
|
|
8 |
|
|
|
9 |
_filedir()
|
|
|
10 |
{
|
|
|
11 |
local i IFS=$'\n' xspec
|
|
|
12 |
|
|
|
13 |
_tilde "$cur" || return 0
|
|
|
14 |
|
|
|
15 |
local -a toks
|
|
|
16 |
local quoted tmp
|
|
|
17 |
|
|
|
18 |
_quote_readline_by_ref "$cur" quoted
|
|
|
19 |
toks=( ${toks[@]-} $(
|
|
|
20 |
compgen -d -- "$quoted" | {
|
|
|
21 |
while read -r tmp; do
|
|
|
22 |
printf '%s\n' $tmp
|
|
|
23 |
done
|
|
|
24 |
}
|
|
|
25 |
))
|
|
|
26 |
|
|
|
27 |
if [[ "$1" != -d ]]; then
|
|
|
28 |
[[ ${BASH_VERSINFO[0]} -ge 4 ]] && \
|
|
|
29 |
xspec=${1:+"!*.@($1|${1^^})"} || \
|
|
|
30 |
xspec=${1:+"!*.@($1|$(printf %s $1 | tr '[:lower:]' '[:upper:]'))"}
|
|
|
31 |
toks=( ${toks[@]-} $( compgen -f -X "$xspec" -- $quoted) )
|
|
|
32 |
fi
|
|
|
33 |
[ ${#toks[@]} -ne 0 ] && _compopt_o_filenames
|
|
|
34 |
|
|
|
35 |
COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" )
|
|
|
36 |
}
|