Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize dots in script names #2275

Merged
merged 1 commit into from Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Expand Up @@ -12,6 +12,7 @@ Unreleased
- Fix return value and type signature of `shell_completion.add_completion_class`
function. :pr:`2421`
- Bash version detection doesn't fail on Windows. :issue:`2461`
- Completion works if there is a dot (``.``) in the program name. :issue:`2166`


Version 8.1.3
Expand Down
6 changes: 5 additions & 1 deletion src/click/core.py
Expand Up @@ -1129,9 +1129,13 @@ def _main_shell_completion(
:param complete_var: Name of the environment variable that holds
the completion instruction. Defaults to
``_{PROG_NAME}_COMPLETE``.

.. versionchanged:: 8.2.0
Dots (``.``) in ``prog_name`` are replaced with underscores (``_``).
"""
if complete_var is None:
complete_var = f"_{prog_name}_COMPLETE".replace("-", "_").upper()
complete_name = prog_name.replace("-", "_").replace(".", "_")
complete_var = f"_{complete_name}_COMPLETE".upper()

instruction = os.environ.get(complete_var)

Expand Down