@@ -853,47 +853,52 @@ _comp_compgen_filedir()
853853 _comp_compgen_tilde && return
854854
855855 local -a toks
856- local arg =${1-}
856+ local _arg =${1-}
857857
858- if [[ $arg == -d ]]; then
858+ if [[ $_arg == -d ]]; then
859859 _comp_compgen -v toks -- -d
860860 else
861861 local ret
862862 _comp_quote_compgen " ${cur-} "
863- local quoted=$ret
863+ local _quoted=$ret
864+ _comp_unlocal ret
864865
865866 # Munge xspec to contain uppercase version too
866867 # https://lists.gnu.org/archive/html/bug-bash/2010-09/msg00036.html
867868 # news://news.gmane.io/4C940E1C.1010304@case.edu
868- local xspec =${arg : +" !*.@($arg |${arg ^^} )" } plusdirs =()
869+ local _xspec =${_arg : +" !*.@($_arg |${_arg ^^} )" } _plusdirs =()
869870
870871 # Use plusdirs to get dir completions if we have a xspec; if we don't,
871872 # there's no need, dirs come along with other completions. Don't use
872873 # plusdirs quite yet if fallback is in use though, in order to not ruin
873874 # 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)
876877 [[ ${BASH_COMPLETION_FILEDIR_FALLBACK-${COMP_FILEDIR_FALLBACK-} } ||
877- ! ${plusdirs -} ]] ||
878- opts +=(" ${plusdirs [@]} " )
878+ ! ${_plusdirs -} ]] ||
879+ _opts +=(" ${_plusdirs [@]} " )
879880
880- _comp_compgen -v toks -c " $quoted " -- " ${opts [@]} "
881+ _comp_compgen -v toks -c " $_quoted " -- " ${_opts [@]} "
881882
882883 # Try without filter if it failed to produce anything and configured to
883884 [[ ${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[@]} " }
886888 fi
887889
888890 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
890893 compopt -o filenames 2> /dev/null
891894 fi
892895
893896 # Note: bash < 4.4 has a bug that all the elements are connected with
894897 # ${v-"${a[@]}"} when IFS does not contain whitespace.
895898 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[@]} " }
897902} # _comp_compgen_filedir()
898903
899904# This function splits $cur=--foo=bar into $prev=--foo, $cur=bar, making it
0 commit comments