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
zsh autocompletion not replacing tabs correctly #105587
Comments
@fandahao17: This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/sig cli |
This appears to be related to which zsh version you are using. At first, I was unable to reproduce the problem, but then realized I have zsh 5.8. So I downloaded and built zsh 5.0.2 to match the version @fandahao17 reported using and am able to reproduce the problem. @fandahao17 Are you able to upgrade to a newer version of zsh? 5.8 worked for me, but I don't know if an earlier version might also work. We should probably figure out what the minimum required version is for zsh completions to work and document it. |
I am also able to reproduce this using Zsh 5.0.x. I can also confirm that the suggested fix does seem to work. @fandahao17 The fix you found is simple enough that it may be worth opening an issue with the https://github.com/spf13/cobra project which generates the completion scripts to try to get it in. |
Please open over on the cobra repo if you'd like to get this fixed there. /close |
@eddiezane: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
A fix for this issue will be part of the next Cobra release: spf13/cobra#1665 |
I've created the PR #112362 to fix this issue, but for those still facing this issue after installing Oh My Zsh with sed -i '6i\ sed -i '\''s/tab=$(printf \x27\\t\x27)/tab="$(printf \x27\\t\x27)"/'\'' "$ZSH_CACHE_DIR/completions/_kubectl"\' ~/.oh-my-zsh/plugins/kubectl/kubectl.plugin.zsh && \
sed -i '9i\ sed -i '\''s/tab=$(printf \x27\\t\x27)/tab="$(printf \x27\\t\x27)"/'\'' "$ZSH_CACHE_DIR/completions/_kubectl"\' ~/.oh-my-zsh/plugins/kubectl/kubectl.plugin.zsh && \
sed -i '12i\ sed -i '\''s/tab=$(printf \x27\\t\x27)/tab="$(printf \x27\\t\x27)"/'\'' "$ZSH_CACHE_DIR/completions/_kubectl"\' ~/.oh-my-zsh/plugins/kubectl/kubectl.plugin.zsh && \
exec zsh |
What happened?
While using zsh autocompletion:
[fandahao@localhost]~% kubectl ge\t
No completion result is given.
When I turn on
$BASH_COMP_DEBUG_FILE
, I see the following logs:I noticed that the last line seems to give weird results. After printing out what
source <(kubectl completion zsh)
does, I think the bug is caused by the following lines:The last line is supposed to replace all
\t
's in the completion result with:
, but it actually replaced all empty strings with a:
.Replacing the last two lines with the following code seems to solve the problem:
comp=${comp//$(printf '\t')/:}
Honestly, I don't know why this works correctly while the original code does not. I guess tabs may need to be treated differently when doing variable expansions?
What did you expect to happen?
After modifying the code as in last section, I got the following logs. I think this is the correct result.
How can we reproduce it (as minimally and precisely as possible)?
A minimal
.zshrc
:Anything else we need to know?
No response
Kubernetes version
Cloud provider
This bug happens on my own machine.
OS version
Install tools
Container runtime (CRI) and and version (if applicable)
Related plugins (CNI, CSI, ...) and versions (if applicable)
The text was updated successfully, but these errors were encountered: