--- /usr/share/bash-completion/bash_completion 2020-09-04 20:39:18.453560935 -0700 +++ /home/xxx/bash_completion 2020-09-04 20:39:13.625394958 -0700 @@ -563,37 +559,28 @@ _tilde "$cur" || return local -a toks - local reset + local x reset - if [[ "$1" == -d ]]; then reset=$(shopt -po noglob); set -o noglob toks=( $(compgen -d -- "$cur") ) - IFS=' '; $reset; IFS=$'\n' - else + eval $reset + + if [[ "$1" != -d ]]; then local quoted _quote_readline_by_ref "$cur" quoted # Munge xspec to contain uppercase version too # http://thread.gmane.org/gmane.comp.shells.bash.bugs/15294/focus=15306 - local xspec=${1:+"!*.@($1|${1^^})"} plusdirs=() - - # Use plusdirs to get dir completions if we have a xspec; if we don't, - # there's no need, dirs come along with other completions. Don't use - # plusdirs quite yet if fallback is in use though, in order to not ruin - # the fallback condition with the "plus" dirs. - local opts=( -f -X "$xspec" ) - [[ $xspec ]] && plusdirs=(-o plusdirs) - [[ ${COMP_FILEDIR_FALLBACK-} ]] || opts+=( "${plusdirs[@]}" ) - + local xspec=${1:+"!*.@($1|${1^^})"} reset=$(shopt -po noglob); set -o noglob - toks+=( $(compgen "${opts[@]}" -- $quoted) ) - IFS=' '; $reset; IFS=$'\n' + toks+=( $( compgen -f -X "$xspec" -- $quoted ) ) + eval $reset # Try without filter if it failed to produce anything and configured to [[ -n ${COMP_FILEDIR_FALLBACK:-} && -n "$1" && ${#toks[@]} -lt 1 ]] && { reset=$(shopt -po noglob); set -o noglob - toks+=( $(compgen -f "${plusdirs[@]}" -- $quoted) ) - IFS=' '; $reset; IFS=$'\n' + toks+=( $( compgen -f -- $quoted ) ) + eval $reset } fi