Skip to content

completion: fix zsh __docker_plugins bad math expression - #7250

Merged
thaJeztah merged 1 commit into
docker:masterfrom
FrancescoCastaldi:fix/2761-zsh-plugins-completion
Aug 31, 2026
Merged

completion: fix zsh __docker_plugins bad math expression#7250
thaJeztah merged 1 commit into
docker:masterfrom
FrancescoCastaldi:fix/2761-zsh-plugins-completion

Conversation

@FrancescoCastaldi

Copy link
Copy Markdown
Contributor

The \TAG\ column no longer exists in \docker plugin ls\ output. When the __docker_plugins\ function tried to extract the non-existent \TAG\ column, the header parser returned an empty string for \�egin[TAG]\ and \end[TAG], which evaluated to \

Comment thread contrib/completion/zsh/_docker Outdated
Comment on lines +1576 to +1578
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]}]}%% ##}}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps instead, it should use --format to get the right fields, e.g.;

docker plugin ls --format='{{.ID}}\t{{.Name}}'
e91da965f5d9	vieux/sshfs:latest

FWIW; we mostly consider these hand-written completion script in "maintenance" mode, as the CLI now provide dynamically generated completion;

docker completion --help
Usage:  docker completion COMMAND

Generate the autocompletion script for docker for the specified shell.
See each sub-command's help for details on how to use the generated script.

Commands:
  bash        Generate the autocompletion script for bash
  fish        Generate the autocompletion script for fish
  powershell  Generate the autocompletion script for powershell
  zsh         Generate the autocompletion script for zsh

Run 'docker completion COMMAND --help' for more information on a command.

@FrancescoCastaldi FrancescoCastaldi Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thaJeztah Thanks! Updated __docker_plugins to use --format '{{.Name}}:{{.ID}}' directly, which is much cleaner and avoids manual column parsing.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@thaJeztah thaJeztah added this to the 29.8.0 milestone Aug 31, 2026
Comment thread contrib/completion/zsh/_docker Outdated
s="$s:${(l:7:: :::)${${line[${begin[TAG]},${end[TAG]}]}%% ##}}"
plugins=($plugins $s)
done
plugins=(${(f)${:-"$(_call_program commands docker $docker_options plugin ls --format '{{.Name}}:{{.ID}}' $args)"$'\n'}})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will use name:id, but name could include a tag, so we may end up with vieux/sshfs:latest:e91da965f5d9.

Probably means that we can't fully get rid of the loop, and still would need to escape the colon in the name (e.g., name="${name//:/\\:}")

@FrancescoCastaldi FrancescoCastaldi Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I've updated __docker_plugins to extract {{.Name}} and {{.ID}} separated by tab, escaping colons in the plugin name and ID (${name//:/\:}) so that _describe correctly handles tags like vieux/sshfs:latest without breaking the description separator.

@FrancescoCastaldi
FrancescoCastaldi force-pushed the fix/2761-zsh-plugins-completion branch from e05a566 to 8c62278 Compare August 31, 2026 12:23
@thaJeztah

Copy link
Copy Markdown
Member

@FrancescoCastaldi can you check again; I see you pushed, but don't think you updated the code?

Use 'docker plugin ls --format' to extract plugin names and IDs, escaping colons in the plugin name (e.g. repo:tag) so zsh _describe treats the ID correctly as description.

Fixes docker#2761

Signed-off-by: FrancescoCastaldi <francesco.castaldi@mapsgroup.it>
@FrancescoCastaldi
FrancescoCastaldi force-pushed the fix/2761-zsh-plugins-completion branch from 8c62278 to 63da0b0 Compare August 31, 2026 15:24
@FrancescoCastaldi

Copy link
Copy Markdown
Contributor Author

@thaJeztah Apologies! Looks like my previous push didn't properly include the updated file changes. I have now pushed the fix using docker plugin ls --format '{{.Name}}\t{{.ID}}', splitting by tab and escaping the colons with ${name//:/\:} so that plugin tags (like
epo:tag) are handled correctly without breaking _describe.

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thx

@thaJeztah
thaJeztah merged commit 5a7e00d into docker:master Aug 31, 2026
95 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants