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

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

Closed
VorpalBlade opened this issue May 2, 2022 · 1 comment · Fixed by #2074
Closed
Labels
bug Something isn't working in dependency In a dependency, not in chezmoi

Comments

@VorpalBlade
Copy link
Contributor

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.

@twpayne twpayne added in dependency In a dependency, not in chezmoi bug Something isn't working labels May 3, 2022
@twpayne
Copy link
Owner

twpayne commented May 3, 2022

Thanks for reporting this. The zsh completion script is generated by github.com/spf13/cobra. I've opened spf13/cobra#1690 with you as co-author to fix this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working in dependency In a dependency, not in chezmoi
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants