K3d: zsh completion file misses escaping characters for opening and closing brackets

Created on 5 Jun 2020  ·  10Comments  ·  Source: rancher/k3d

Reproduction:

  • Install k3d
  • Run mkdir -p ~/.oh-my-zsh/custom/plugins/k3d
  • Run k3d completion zsh > ~/.oh-my-zsh/custom/plugins/k3d/_k3d
  • Run rm -f ~/.zcompdump* && source .zshrc
  • Try k3d <tab>

The following error occures:
_arguments:comparguments:325: invalid option definition: (-r --runtime)-r[Choose a container runtime environment [docker, containerd]]:

After escaping (almost) every opening and closing bracked, code completion works. See file attached for patched completion file

_k3d.txt

bug

All 10 comments

Hi there, thanks for opening this issue!
Which version of k3d are you using?
I just implemented new completion yesterday and tested it without problems in bash, zsh and psh 🤔

Hey,
I'm using the current release candidate:

❯ k3d version
k3d version v3.0.0-rc.1
k3s version v1.18.3-k3s1 (default)

Maybe it's about oh-my-zsh? Or did you clean your completion cache when testing?

Okay, that's cool, because the latest RC including the completion stuff ist RC.2 🙂
Could you please test this?
See https://github.com/rancher/k3d/releases/tag/v3.0.0-rc.2
I just did:

  • k3d completion > ~/.zsh/completion/_k3d
  • exec $SHELL -1
  • all the tests

I get the same errors when using k3d version v3.0.0-rc.2. The completion file that renezoller has attached works.
I don't use oh-my-zsh.

Hey, I tried rc2. Same problem as before. When I escape the brackets everything works fine.

Hi there again, I just checked this again and you're absolutely right, that it doesn't work with the binaries attached to the release. I honestly don't know why :thinking:
I'm building this locally (for linux and cross-builds) and get no errors...
I hope this is fixed in the next RC release.

Hey @renezoller & @muc can you please try again with the latest RC.3?
I tested it like this (in zsh):
` $ rm ~/.zsh/completions/_k3d # remove existing completion file $ exec $SHELL -1 # reload shell $ k3d <TAB> # test to verify that there's no completion $ k3d completion zsh > ~/.zsh/completions/_k3d # generate new completion file $ exec $SHELL -1 # reload shell $ k3d <TAB> # test to verify that completion works

I've tested in on RC.3 and worked for me.

Worked for me, too. Thank you!

Great :)

Was this page helpful?
0 / 5 - 0 ratings