Run zsh with docker installed and the docker completion working.
Make sure there's at least one docker plugin installed so that docker plugin ls shows at least one row. For example: docker plugin install vieux/sshfs.
Try to complete docker inspect <TAB>
Describe the results you received:
The shell outputs multiple __docker_plugins:27: bad math expression: empty string error messages and the completion entries are all garbled.
Describe the results you expected:
A list of Docker objects available to be inspected.
Additional information you deem important (e.g. issue happens only occasionally):
I've tracked down the problem to the __docker_plugins function, which expects the output of docker plugin ls to have a TAG column, which it doesn't. I believe the solution is to use the ID column instead, but I haven't used docker plugins before so I may be wrong.
I've also seen that just modifying the function to use the ID column isn't enough to make the results of the function correct, since it also tries to truncate the ID hash to 7 characters, but it truncates the beginning characters of the string, not the ending ones. This is I believe what would make the function work correctly:
diff --git a/contrib/completion/zsh/_docker b/contrib/completion/zsh/_docker
index 4d28ac4..82a77de 100644
--- a/contrib/completion/zsh/_docker
+++ b/contrib/completion/zsh/_docker
@@ -1582,7 +1582,7 @@ __docker_plugins() {
# Name
for line in $lines; do
s="${line[${begin[NAME]},${end[NAME]}]%% ##}"
- s="$s:${(l:7:: :::)${${line[${begin[TAG]},${end[TAG]}]}%% ##}}"
+ s="$s:${(r:7:: :::)${${line[${begin[ID]},${end[ID]}]}%% ##}}"
plugins=($plugins $s)
done
Description
Steps to reproduce the issue:
docker plugin ls
shows at least one row. For example:docker plugin install vieux/sshfs
.docker inspect <TAB>
Describe the results you received:
The shell outputs multiple
__docker_plugins:27: bad math expression: empty string
error messages and the completion entries are all garbled.Describe the results you expected:
A list of Docker objects available to be inspected.
Additional information you deem important (e.g. issue happens only occasionally):
I've tracked down the problem to the
__docker_plugins
function, which expects the output ofdocker plugin ls
to have aTAG
column, which it doesn't. I believe the solution is to use theID
column instead, but I haven't used docker plugins before so I may be wrong.I've also seen that just modifying the function to use the
ID
column isn't enough to make the results of the function correct, since it also tries to truncate the ID hash to 7 characters, but it truncates the beginning characters of the string, not the ending ones. This is I believe what would make the function work correctly:Related issue: https://github.com/ohmyzsh/ohmyzsh/issues/9294
Output of
docker version
:Output of
docker info
:Additional environment details (AWS, VirtualBox, physical, etc.):
Using Ubuntu 19.10 on WSL2 but I don't think it makes a difference.