浏览代码

fix(ssh-agent): add identity only if identity exists (#12371)

Zikoeng Xi 3 周之前
父节点
当前提交
67581c53c6
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      plugins/ssh-agent/ssh-agent.plugin.zsh

+ 1 - 1
plugins/ssh-agent/ssh-agent.plugin.zsh

@@ -62,7 +62,7 @@ function _add_identities() {
     # if id is an absolute path, make file equal to id
     [[ "$id" = /* ]] && file="$id" || file="$HOME/.ssh/$id"
     # check for filename match, otherwise try for signature match
-    if [[ ${loaded_ids[(I)$file]} -le 0 ]]; then
+    if [[ -f $file && ${loaded_ids[(I)$file]} -le 0 ]]; then
       sig="$(ssh-keygen -lf "$file" | awk '{print $2}')"
       [[ ${loaded_sigs[(I)$sig]} -le 0 ]] && not_loaded+=("$file")
     fi