Skip to content

Commit

Permalink
fix(_comp_compgen_filedir_xspec): fix for empty "toks" and simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Aug 11, 2024
1 parent c7b915b commit c5febe4
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -3051,15 +3051,11 @@ _comp_compgen_filedir_xspec()
((${#toks[@]})) || return 1
# Remove . and .. (as well as */. and */..) from suggestions,
# unless .. or */.. was typed explicitly by the user
# (for users who use tab-completion to append a slash after '..')
if [[ ${cur} != @(..|*/..) ]]; then
local i
for i in "${!toks[@]}"; do
[[ ${toks[$i]} == @(.|..|*/.|*/..) ]] &&
unset -v "toks[$i]"
done
# Remove . and .. (as well as */. and */..) from suggestions, unless .. or
# */.. was typed explicitly by the user (for users who use tab-completion
# to append a slash after '..')
if [[ $cur != ?(*/).. ]]; then
_comp_compgen -Rv toks -- -X '?(*/)@(.|..)' -W '"${toks[@]}"' || return 1
fi
compopt -o filenames
Expand Down

0 comments on commit c5febe4

Please sign in to comment.