diff --git a/.bashrc b/.bashrc index 669afe9..cad450f 100644 --- a/.bashrc +++ b/.bashrc @@ -6,7 +6,7 @@ _agent_prompt_command() { # Check the ssh agent socket is still alive. # Need to work around an ssh-add bug here: ssh-add doesn't always return 2 on failure # to contact the agent, so also check if any errors were produced. - OUTPUT=$(ssh-add -l >/dev/null) + OUTPUT=$(ssh-add -l 2>&1 >/dev/null) if ((${PIPESTATUS[0]} >= 2)) || [[ ! -z "$OUTPUT" ]]; then # Auth socket has become unusable, search for a new one. SOCK="$(_find_agent_sock)" @@ -40,7 +40,7 @@ _clean_agent_socks() { local I OUTPUT SSH_AUTH_SOCK # Go through the array of sockets and validate each one. for ((I = 0; I < ${#SOCKS[@]}; I++)); do - OUTPUT="$(SSH_AUTH_SOCK="${SOCKS[$I]}" ssh-add -l >/dev/null)" + OUTPUT="$(SSH_AUTH_SOCK="${SOCKS[$I]}" ssh-add -l 2>&1 >/dev/null)" ((${PIPESTATUS[0]} >= 2)) || [[ ! -z "$OUTPUT" ]] && { unset SOCKS[$I] } @@ -59,7 +59,7 @@ _find_agent_sock() { fi # Search backwards through the list to find an active socket. for ((I = (${#SOCKS[@]} - 1); I >= 0; I--)); do - OUTPUT="$(SSH_AUTH_SOCK="${SOCKS[$I]}" ssh-add -l >/dev/null)" + OUTPUT="$(SSH_AUTH_SOCK="${SOCKS[$I]}" ssh-add -l 2>&1 >/dev/null)" { ((${PIPESTATUS[0]} <= 1)) && [[ -z "$OUTPUT" ]]; } && [[ ! -z "${SOCKS[$I]}" ]] && { printf "%s" "${SOCKS[$I]}" return 0