]>
git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - bash-completion/bash-completion-1.99-redefine_filedir.bash
1 # This is a copy of the _filedir function in bash_completion, included
2 # and (re)defined separately here because some versions of Adobe
3 # Reader, if installed, are known to override this function with an
4 # incompatible version, causing various problems.
6 # https://bugzilla.redhat.com/677446
7 # http://forums.adobe.com/thread/745833
11 local i IFS
=$
'\n' xspec
13 _tilde
"$cur" ||
return 0
18 _quote_readline_by_ref
"$cur" quoted
20 compgen
-d -- "$quoted" |
{
22 # TODO: I have removed a "[ -n $tmp ] &&" before 'printf ..',
23 # and everything works again. If this bug suddenly
24 # appears again (i.e. "cd /b<TAB>" becomes "cd /"),
25 # remember to check for other similar conditionals (here
26 # and _filedir_xspec()). --David
32 if [[ "$1" != -d ]]; then
33 # Munge xspec to contain uppercase version too
34 # http://thread.gmane.org/gmane.comp.shells.bash.bugs/15294/focus=15306
35 xspec
=${1:+"!*.@($1|${1^^})"}
36 toks
+=( $
( compgen
-f -X "$xspec" -- $quoted ) )
39 # If the filter failed to produce anything, try without it if configured to
40 [[ -n ${COMP_FILEDIR_FALLBACK:-} && \
41 -n "$1" && "$1" != -d && ${#toks[@]} -lt 1 ]] && \
42 toks
+=( $
( compgen
-f -- $quoted ) )
44 if [[ ${#toks[@]} -ne 0 ]]; then
45 # 2>/dev/null for direct invocation, e.g. in the _filedir unit test
46 compopt
-o filenames
2>/dev
/null
47 COMPREPLY
+=( "${toks[@]}" )