Skip to content

Commit 76c035a

Browse files
committed
perf(filedir_xspec): avoid double negation !(!(...)) in extglob
Nested negations becomes extremely slow for a long filename.
1 parent d41d744 commit 76c035a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

bash_completion

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3197,14 +3197,14 @@ _comp_compgen_filedir_xspec()
31973197
# https://lists.gnu.org/archive/html/bug-bash/2010-09/msg00036.html
31983198
# news://news.gmane.io/4C940E1C.1010304@case.edu
31993199
eval xspec="${xspec}"
3200-
local matchop=!
32013200
if [[ $xspec == !* ]]; then
32023201
xspec=${xspec#!}
3203-
matchop=@
3202+
xspec="@(|!($xspec|${xspec^^}))"
3203+
else
3204+
xspec="@(|$xspec|${xspec^^})"
32043205
fi
3205-
xspec="$matchop($xspec|${xspec^^})"
32063206
3207-
_comp_compgen -av toks -c "$quoted" -- -f -X "@(|!($xspec))"
3207+
_comp_compgen -av toks -c "$quoted" -- -f -X "$xspec"
32083208
32093209
# Try without filter if it failed to produce anything and configured to
32103210
[[ ${BASH_COMPLETION_FILEDIR_FALLBACK-} && ${#toks[@]} -lt 1 ]] &&

0 commit comments

Comments
 (0)