diff options
author | Marc Cornellà <hello@mcornella.com> | 2021-09-15 18:18:25 +0200 |
---|---|---|
committer | Marc Cornellà <hello@mcornella.com> | 2021-09-15 18:18:25 +0200 |
commit | 4e6e49652b69557c01ef1ce81c96da7eb9b34e6e (patch) | |
tree | 70f6f8f2610a60636d5f8b9acf5c3b784a1631b2 /plugins/rustup | |
parent | c21ff38b8fda0584208ffd697dac0502e2327466 (diff) | |
download | zsh-4e6e49652b69557c01ef1ce81c96da7eb9b34e6e.tar.gz zsh-4e6e49652b69557c01ef1ce81c96da7eb9b34e6e.tar.bz2 zsh-4e6e49652b69557c01ef1ce81c96da7eb9b34e6e.zip |
fix(plugins): fix `_comps` error in completion generation plugins (#10190)
Fixes #10190
Diffstat (limited to 'plugins/rustup')
-rw-r--r-- | plugins/rustup/rustup.plugin.zsh | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/plugins/rustup/rustup.plugin.zsh b/plugins/rustup/rustup.plugin.zsh index c7a9b3060..e709f41bd 100644 --- a/plugins/rustup/rustup.plugin.zsh +++ b/plugins/rustup/rustup.plugin.zsh @@ -1,12 +1,16 @@ -# COMPLETION FUNCTION if (( $+commands[rustup] )); then - if [[ ! -f $ZSH_CACHE_DIR/rustup_version ]] \ - || [[ "$(rustup --version 2> /dev/null)" \ - != "$(< "$ZSH_CACHE_DIR/rustup_version")" ]] \ - || [[ ! -f $ZSH/plugins/rustup/_rustup ]]; then - rustup completions zsh > $ZSH/plugins/rustup/_rustup - rustup --version 2> /dev/null > $ZSH_CACHE_DIR/rustup_version + ver="$(rustup --version 2>/dev/null)" + ver_file="$ZSH_CACHE_DIR/rustup_version" + comp_file="$ZSH/plugins/rustup/_rustup" + + if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then + rustup completions zsh >| "$comp_file" + echo "$ver" >| "$ver_file" fi + + declare -A _comps autoload -Uz _rustup _comps[rustup]=_rustup + + unset ver ver_file comp_file fi |