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 1843ad5 commit 8dd381d
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 8dd381d

Please sign in to comment.