fix(ssh-agent): change input processing

This commit is contained in:
achevsmisle 2026-06-20 18:54:31 +03:00
commit f0fda90a24
No known key found for this signature in database
GPG key ID: 918BC2BA80ECB278

View file

@ -23,24 +23,22 @@ function _start_agent() {
# override $SSH_AUTH_SOCK path option # override $SSH_AUTH_SOCK path option
if zstyle -t :omz:plugins:ssh-agent override-agent-socket-path; then if zstyle -t :omz:plugins:ssh-agent override-agent-socket-path; then
local ssh_auth_sock_path local ssh_agent_sock_path
local sock_path_reply zstyle -s :omz:plugins:ssh-agent ssh_agent_sock_path ssh_agent_sock_path
zstyle -g sock_path_reply :omz:plugins:ssh-agent override-agent-socket-path
ssh_auth_sock_path="$sock_path_reply"
# set fallback path by $OSTYPE # set fallback path by $OSTYPE
if [[ -z "$ssh_auth_sock_path" ]]; then if [[ -z "$ssh_agent_sock_path" ]]; then
if [[ "$OSTYPE" == "linux"* ]]; then if [[ "$OSTYPE" == "linux"* ]]; then
ssh_auth_sock_path="/var/run/user/$UID/ssh-agent" ssh_agent_sock_path="/var/run/user/$UID/ssh-agent"
elif [[ "$OSTYPE" == "darwin"* ]]; then elif [[ "$OSTYPE" == "darwin"* ]]; then
ssh_auth_sock_path="${TMPDIR:-/tmp}/ssh-agent.socket" ssh_agent_sock_path="${TMPDIR:-/tmp}/ssh-agent.socket"
else else
ssh_auth_sock_path="$HOME/.ssh/ssh-agent.socket" ssh_agent_sock_path="$HOME/.ssh/ssh-agent.socket"
fi fi
fi fi
# check the socket dir and create if needed # check the socket dir and create if needed
local socket_dir="${ssh_auth_sock_path:h}" local socket_dir="${ssh_agent_sock_path:h}"
if [[ ! -d "$socket_dir" ]]; then if [[ ! -d "$socket_dir" ]]; then
mkdir -p "$socket_dir" || \ mkdir -p "$socket_dir" || \
{ echo "Error: can't create ssh socket parent directory." && return 1 } { echo "Error: can't create ssh socket parent directory." && return 1 }
@ -49,7 +47,7 @@ function _start_agent() {
fi fi
# set extra flags array # set extra flags array
agent_extra_flags=(-a "$ssh_auth_sock_path") agent_extra_flags=(-a "$ssh_agent_sock_path")
fi fi
# Set a maximum lifetime for identities added to ssh-agent # Set a maximum lifetime for identities added to ssh-agent