Skip to content

Bug in zsh completion of chezmoi: it incorrectly also completes the completion itself #2047

@VorpalBlade

Description

@VorpalBlade

Describe the bug

The first line in the chezmoi zsh completion is currently (and incorrectly):

#compdef _chezmoi chezmoi

ZSH interprets that as the file containing completion for chezmoi as well as _chezmoi. However, _chezmoi is the completion function itself, and should not be completed by itself (it shouldn't be completed at all).

When experimenting trying to tab complete arguments to _chezmoi results in zsh hanging (so something is really broken there, probably that to the line requestComp="${words[1]} __complete ${words[2,-1]}" results in a recursive call to _chezmoi).

The fix is easy though, change the first line to:

#compdef chezmoi

To reproduce

  1. Try to tab complete _chezmoi in zsh.
  2. Observe hang.

Expected behavior

Only chezmoi should have tab completion.

Output of command with the --verbose flag

Not applicable.

Output of chezmoi doctor

$ chezmoi doctor
RESULT    CHECK                MESSAGE
warning   version              v2.15.2, built at 2022-05-01T17:26:37Z
ok        latest-version       v2.15.2
ok        os-arch              linux/amd64 (Arch Linux)
ok        uname                Linux athena 5.17.5-arch1-1 #1 SMP PREEMPT Wed, 27 Apr 2022 20:56:11 +0000 x86_64 GNU/Linux
ok        go-version           go1.18.1 (gc)
ok        executable           /usr/bin/chezmoi
ok        config-file          ~/.config/chezmoi/chezmoi.yaml
ok        source-dir           ~/.local/share/chezmoi is a directory
ok        suspicious-entries   no suspicious entries
ok        working-tree         ~/.local/share/chezmoi is a directory
ok        dest-dir             ~ is a directory
ok        shell-command        found /bin/zsh
ok        shell-args           /bin/zsh
ok        cd-command           found /bin/zsh
ok        cd-args              /bin/zsh
ok        edit-command         found /usr/bin/code
ok        edit-args            /usr/bin/code -wr
info      diff-command         not set
ok        umask                022
ok        git-command          found /usr/bin/git, version 2.36.0
ok        merge-command        found /usr/bin/bcompare
info      age-command          age not found in $PATH
ok        gpg-command          found /usr/bin/gpg, version 2.2.35
info      pinentry-command     not set
info      1password-command    op not found in $PATH
info      bitwarden-command    bw not found in $PATH
info      gopass-command       gopass not found in $PATH
ok        keepassxc-command    found /usr/bin/keepassxc-cli, version 2.7.1
info      keepassxc-db         not set
info      lastpass-command     lpass not found in $PATH
info      pass-command         pass not found in $PATH
info      vault-command        vault not found in $PATH
info      secret-command       not set

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingin dependencyIn a dependency, not in chezmoi

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions