fix(docker): resolve completion path correctly (#14004)

Use `${0:A:h}` to get the absolute plugin directory path before entering
the anonymous function, where `$0` refers to the function itself. Store
it in a local variable to ensure the completion file path is resolved
correctly.

Fixes #14003
This commit is contained in:
ディレーン
2026-08-24 18:33:49 +02:00
committed by GitHub
parent 67462daf46
commit ec03bc620c

View File

@@ -58,14 +58,17 @@ fi
zmodload -F zsh/files b:zf_mv
() {
local plugin_dir="$1"
# `docker completion` is only available from 23.0.0 on
# docker version returns `Docker version 24.0.2, build cb74dfcd85`
# with `s:,:` remove the comma after the version, and select third word of it
if zstyle -t ':omz:plugins:docker' legacy-completion || \
! is-at-least 23.0.0 ${${(s:,:z)"$(command docker --version)"}[3]}; then
command cp "${0:h}/completions/_docker" "$ZSH_CACHE_DIR/completions/_docker"
command cp "${plugin_dir}/completions/_docker" "$ZSH_CACHE_DIR/completions/_docker"
else
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_docker"
zf_mv -f -- =( command docker completion zsh ) "$TMPPREFIX"
fi
} &|
} "${0:A:h}" &|