@@ -853,47 +853,52 @@ _comp_compgen_filedir()
853
853
_comp_compgen_tilde && return
854
854
855
855
local -a toks
856
- local arg =${1-}
856
+ local _arg =${1-}
857
857
858
- if [[ $arg == -d ]]; then
858
+ if [[ $_arg == -d ]]; then
859
859
_comp_compgen -v toks -- -d
860
860
else
861
861
local ret
862
862
_comp_quote_compgen " ${cur-} "
863
- local quoted=$ret
863
+ local _quoted=$ret
864
+ _comp_unlocal ret
864
865
865
866
# Munge xspec to contain uppercase version too
866
867
# https://lists.gnu.org/archive/html/bug-bash/2010-09/msg00036.html
867
868
# news://news.gmane.io/[email protected]
868
- local xspec =${arg : +" !*.@($arg |${arg ^^} )" } plusdirs =()
869
+ local _xspec =${_arg : +" !*.@($_arg |${_arg ^^} )" } _plusdirs =()
869
870
870
- # Use plusdirs to get dir completions if we have a xspec; if we don't,
871
+ # Use _plusdirs to get dir completions if we have a xspec; if we don't,
871
872
# there's no need, dirs come along with other completions. Don't use
872
- # plusdirs quite yet if fallback is in use though, in order to not ruin
873
+ # _plusdirs quite yet if fallback is in use though, in order to not ruin
873
874
# the fallback condition with the "plus" dirs.
874
- local opts =(-f -X " $xspec " )
875
- [[ $xspec ]] && plusdirs =(-o plusdirs )
875
+ local _opts =(-f -X " $_xspec " )
876
+ [[ $_xspec ]] && _plusdirs =(-o _plusdirs )
876
877
[[ ${BASH_COMPLETION_FILEDIR_FALLBACK-${COMP_FILEDIR_FALLBACK-} } ||
877
- ! ${plusdirs -} ]] ||
878
- opts +=(" ${plusdirs [@]} " )
878
+ ! ${_plusdirs -} ]] ||
879
+ _opts +=(" ${_plusdirs [@]} " )
879
880
880
- _comp_compgen -v toks -c " $quoted " -- " ${opts [@]} "
881
+ _comp_compgen -v toks -c " $_quoted " -- " ${_opts [@]} "
881
882
882
883
# Try without filter if it failed to produce anything and configured to
883
884
[[ ${BASH_COMPLETION_FILEDIR_FALLBACK-${COMP_FILEDIR_FALLBACK-} } &&
884
- $arg && ${# toks[@]} -lt 1 ]] &&
885
- _comp_compgen -av toks -c " $quoted " -- -f ${plusdirs+" ${plusdirs[@]} " }
885
+ $_arg && ${# toks[@]} -lt 1 ]] &&
886
+ _comp_compgen -av toks -c " $_quoted " -- \
887
+ -f ${_plusdirs+" ${_plusdirs[@]} " }
886
888
fi
887
889
888
890
if (( ${# toks[@]} != 0 )) ; then
889
- # 2>/dev/null for direct invocation, e.g. in the _comp_compgen_filedir unit test
891
+ # 2>/dev/null for direct invocation, e.g. in the _comp_compgen_filedir
892
+ # unit test
890
893
compopt -o filenames 2> /dev/null
891
894
fi
892
895
893
896
# Note: bash < 4.4 has a bug that all the elements are connected with
894
897
# ${v-"${a[@]}"} when IFS does not contain whitespace.
895
898
local IFS=$' \t\n '
896
- _comp_compgen_set ${toks[@]+" ${toks[@]} " }
899
+ local -a _tmp=(${toks[@]+" ${toks[@]} " } )
900
+ _comp_unlocal toks
901
+ _comp_compgen_set ${_tmp[@]+" ${_tmp[@]} " }
897
902
} # _comp_compgen_filedir()
898
903
899
904
# This function splits $cur=--foo=bar into $prev=--foo, $cur=bar, making it
0 commit comments