Skip to content

Commit 8dd381d

Browse files
committed
fix(_comp_compgen_filedir_xspec): fix for empty "toks" and simplify
1 parent 1843ad5 commit 8dd381d

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

bash_completion

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3051,15 +3051,11 @@ _comp_compgen_filedir_xspec()
30513051
30523052
((${#toks[@]})) || return 1
30533053
3054-
# Remove . and .. (as well as */. and */..) from suggestions,
3055-
# unless .. or */.. was typed explicitly by the user
3056-
# (for users who use tab-completion to append a slash after '..')
3057-
if [[ ${cur} != @(..|*/..) ]]; then
3058-
local i
3059-
for i in "${!toks[@]}"; do
3060-
[[ ${toks[$i]} == @(.|..|*/.|*/..) ]] &&
3061-
unset -v "toks[$i]"
3062-
done
3054+
# Remove . and .. (as well as */. and */..) from suggestions, unless .. or
3055+
# */.. was typed explicitly by the user (for users who use tab-completion
3056+
# to append a slash after '..')
3057+
if [[ $cur != ?(*/).. ]]; then
3058+
_comp_compgen -Rv toks -- -X '?(*/)@(.|..)' -W '"${toks[@]}"' || return 1
30633059
fi
30643060
30653061
compopt -o filenames

0 commit comments

Comments
 (0)