fix: load completion files atomically (#14000)

Fixes #13964
 
Co-authored-by: Marc Cornellà <marc@mcornella.com>
This commit is contained in:
Carlo Sala
2026-08-22 17:24:24 +02:00
committed by GitHub
parent d42209f2af
commit 830a5bcfd2
47 changed files with 248 additions and 56 deletions

View File

@@ -56,7 +56,8 @@ if [[ ! -f "$ZSH_CACHE_DIR/completions/_docker" ]]; then
_comps[docker]=_docker
fi
{
zmodload -F zsh/files b:zf_mv
() {
# `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
@@ -64,6 +65,7 @@ fi
! is-at-least 23.0.0 ${${(s:,:z)"$(command docker --version)"}[3]}; then
command cp "${0:h}/completions/_docker" "$ZSH_CACHE_DIR/completions/_docker"
else
command docker completion zsh | tee "$ZSH_CACHE_DIR/completions/_docker" > /dev/null
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_docker"
zf_mv -f -- =( command docker completion zsh ) "$TMPPREFIX"
fi
} &|