completion: fix zsh __docker_plugins bad math expression - #7250
Conversation
| 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]}]}%% ##}}" |
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.There was a problem hiding this comment.
@thaJeztah Thanks! Updated __docker_plugins to use --format '{{.Name}}:{{.ID}}' directly, which is much cleaner and avoids manual column parsing.
c4dd093 to
e05a566
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
| 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'}}) |
There was a problem hiding this comment.
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//:/\\:}")
There was a problem hiding this comment.
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.
e05a566 to
8c62278
Compare
|
@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>
8c62278 to
63da0b0
Compare
|
@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 |
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 \