New Ticket     Tickets     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Ticket #35090 (closed defect: fixed)

Opened 11 months ago

Last modified 11 months ago

Running bash_completion script is slow, due to have() function

Reported by: justin.lebar@… Owned by: raimue@…
Priority: Normal Milestone:
Component: ports Version: 2.1.1
Keywords: Cc:
Port: bash-completion

Description

$ time bash /opt/local/etc/bash_completion
real	0m2.954s
user	0m0.078s
sys	0m0.037s

If I modify the have() function so it returns 0 (instead of running |type|) I get

$ time bash /opt/local/etc/bash_completion
real	0m0.245s
user	0m0.059s
sys	0m0.010s

I'm totally in favor of not loading complex completion scripts for commands that aren't installed, but that doesn't appear to be what's happening here; have() guards only very basic completion for some commands, afaict.

Making opening a new terminal window 10x slower for the sake of avoiding some |complete| calls seems like a premature optimization and a bad trade-off.

Change History

comment:1 Changed 11 months ago by cal@…

  • Owner changed from macports-tickets@… to raimue@…

comment:2 Changed 11 months ago by raimue@…

  • Status changed from new to assigned

This is a known issue with bash-completion which is present on all distributions and not only in MacPorts. This will be fixed in bash-completion 2.0, where the loading of scripts will be deferred until they are used the first time.

As of now, bash-completion 2.0 is only available as a development version in MacPorts in the bash-completion-devel port. I will switch bash-completion to version 2.0 in the near future.

comment:3 Changed 11 months ago by raimue@…

  • Status changed from assigned to closed
  • Resolution set to fixed
  • Port set to bash-completion

bash-completion and bash-completion-devel are now both version 2.0 as of r95135.

comment:4 Changed 11 months ago by justin.lebar@…

Thank you for fixing this so quickly!

Note: See TracTickets for help on using tickets.