Skip to content
Myr

Merge pull request #775 from stopthatcow/feature/faster_bash_completion

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Use fast_exit when invoking bash completion to save about 10ms.

authored by Markus Unterwaditzer · committed by GitHub · parents eb0dcd4, 103c1da · Browse files · 1 file+10 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−1 removed

  • other:+10 added−1 removed

1 file+10 added−1 removed

modified:click/core.py+10 added-1 removed
23 unmodified lines
24SUBCOMMAND_METAVAR = 'COMMAND [ARGS]...'25SUBCOMMANDS_METAVAR = 'COMMAND1 [ARGS]... [COMMAND2 [ARGS]...]...'262728def fast_exit(code):29 """Exit without garbage collection, this speeds up exit by about 10ms for30 things like bash completion.31 """32 sys.stdout.flush()33 sys.stderr.flush()34 os._exit(code)353637def _bashcomplete(cmd, prog_name, complete_var=None):38 """Internal handler for the bash completion support."""39 if complete_var is None:40 complete_var = '_%s_COMPLETE' % (prog_name.replace('-', '_')).upper()
2 unmodified lines
43 return4445 from ._bashcomplete import bashcomplete46 if bashcomplete(cmd, prog_name, complete_var, complete_instr):38 sys.exit(1)47 fast_exit(1)484950def _check_multicommand(base_command, cmd_name, cmd, register=False):51 if not base_command.chain or not isinstance(cmd, MultiCommand):
1714 unmodified lines