completion: fix zsh __docker_plugins bad math expression - #7250
Open
FrancescoCastaldi wants to merge 1 commit into
Open
completion: fix zsh __docker_plugins bad math expression#7250FrancescoCastaldi wants to merge 1 commit into
FrancescoCastaldi wants to merge 1 commit into
Conversation
The TAG column no longer exists in 'docker plugin ls' output. When the function tried to extract the non-existent TAG column, it received an empty string, which caused a 'bad math expression' error in zsh. Fix by reading the ID column instead, and correct the padding direction from l: (left-pad) to r: (right-truncate) so that IDs are correctly shortened to 7 characters from the right. Fixes docker#2761
thaJeztah
reviewed
Aug 27, 2026
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]}]}%% ##}}" |
Member
There was a problem hiding this comment.
Perhaps instead, it should use --format to get the right fields, e.g.;
docker plugin ls --format='{{.ID}}\t{{.Name}}'
e91da965f5d9 vieux/sshfs:latestFWIW; 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 \