From 9d93dfaa60ccc7980ad69b75b1accae0232e4e8f Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Sat, 15 Nov 2025 11:39:09 -0300 Subject: [PATCH] fix(keychain): use pattern matching to detect version (#13423) --- plugins/keychain/keychain.plugin.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/keychain/keychain.plugin.zsh b/plugins/keychain/keychain.plugin.zsh index ce5351bce..23cf1af9a 100644 --- a/plugins/keychain/keychain.plugin.zsh +++ b/plugins/keychain/keychain.plugin.zsh @@ -20,10 +20,11 @@ function { zstyle -a :omz:plugins:keychain options options # Check keychain version to decide whether to use --agents - local version_string=$(keychain --version 2>&1 | head -n 2 | tail -n 1 | cut -d ' ' -f 4) + local version_string=$(keychain --version 2>&1) # start keychain, only use --agents for versions below 2.9.0 autoload -Uz is-at-least - if is-at-least 2.9 "$version_string"; then + if [[ "$version_string" =~ 'keychain ([0-9]+\.[0-9]+)' ]] && \ + is-at-least 2.9 "$match[1]"; then keychain ${^options:-} ${^identities} --host $SHORT_HOST else keychain ${^options:-} --agents ${agents:-gpg} ${^identities} --host $SHORT_HOST