Skip to content

Long option completion with = broken #2847

Description

@brandon-avantus

When using Click shell completion in bash and zsh, long option completion is not working properly when = is used to separate the option from the value (e.g., command --long-option=value vs. command --long-option value). In zsh, the option being completed is replaced with the incomplete value or matched value, essentially "gobbling" up the option. In bash, the option isn't completed at all. I did not test fish.

Steps to reproduce the issue

  1. Create the following script and place it in the bin directory of an activated virtual environment with click installed:
# gobble

#!/usr/bin/env python
import click


@click.command
@click.option("--color", type=click.Choice(["auto", "always", "never"]), default=None,
              help="Control colors in output.")
@click.option("--name",
              help="Name of something.")
def main(color: str | None, name: str | None) -> None:
    """Test long options."""
    click.echo(f"{color=}, {name=}")


if __name__ == "__main__":
    main()
  1. Open a zsh shell and enable script completion: eval "$(_GOBBLE_COMPLETE=zsh_source gobble)"

  2. Attempt to tab complete the --color option using both styles

before tab completion after tab completion offered completions
gobble --color= gobble
gobble --color=a gobble a
gobble --color=al gobble always
gobble --color gobble --color auto always never
gobble --color a gobble --color a auto always
gobble --color al gobble --color always
  1. Open a bash shell and enable script completion: eval "$(_GOBBLE_COMPLETE=bash_source gobble)"

  2. Attempt to tab complete the --color option using both styles

before tab completion after tab completion offered completions
gobble --color= gobble --color= auto always never
gobble --color=a gobble --color=a
gobble --color=al gobble --color=al
gobble --color gobble --color auto always never
gobble --color a gobble --color a auto always
gobble --color al gobble --color always

Expected behavior

before tab completion after tab completion offered completions alternate completions
gobble --color= gobble --color= auto always never --color=auto --color=always --color=never
gobble --color=a gobble --color=a auto always --color=auto --color=always
gobble --color=al gobble --color=always
gobble --color gobble --color auto always never
gobble --color a gobble --color a auto always
gobble --color al gobble --color always

Environment:

  • Python version: 3.12.7
  • Click version: 8.1.8

Activity

  1. added this to the 8.2.1 milestone on May 10, 2025
  2. modified the milestones: 8.2.1, 8.2.2 on May 14, 2025
  3. modified the milestones: 8.2.2, on Jul 16, 2025
  4. removed this from the milestone on Aug 3, 2025
  5. added a commit that references this issue on Apr 5, 2026
    8e072f4
  6. deleted a comment from enestanrikuluu on Jun 12, 2026
  7. deleted a comment from mangodxd on Jul 7, 2026
  8. hiSandog commented on Jul 14, 2026

    @hiSandog

    A table-driven regression test around command --long-option=value could cover the default, explicit, and invalid configuration cases for “Long option completion with = broken”. That would make the compatibility boundary and the expected fallback behavior precise.

  9. deleted a comment from chiruu12 on Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions