Skip to content

Commit

Permalink
perf(filedir_xspec): avoid double negation !(!(...)) in extglob
Browse files Browse the repository at this point in the history
Nested negations becomes extremely slow for a long filename.
  • Loading branch information
akinomyoga committed May 13, 2024
1 parent 3d583df commit 1fd0d1f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -3025,14 +3025,14 @@ _comp_compgen_filedir_xspec()
# https://lists.gnu.org/archive/html/bug-bash/2010-09/msg00036.html
# news://news.gmane.io/4C940E1C.1010304@case.edu
eval xspec="${xspec}"
local matchop=!
if [[ $xspec == !* ]]; then
xspec=${xspec#!}
matchop=@
xspec="@(|!($xspec|${xspec^^}))"
else
xspec="@(|$xspec|${xspec^^})"
fi
xspec="$matchop($xspec|${xspec^^})"
_comp_compgen -av toks -c "$quoted" -- -f -X "@(|!($xspec))"
_comp_compgen -av toks -c "$quoted" -- -f -X "$xspec"
# Try without filter if it failed to produce anything and configured to
[[ ${BASH_COMPLETION_FILEDIR_FALLBACK-} && ${#toks[@]} -lt 1 ]] &&
Expand Down

0 comments on commit 1fd0d1f

Please sign in to comment.