Reorder the redirections to prevent errors being displayed when they shouldn't be.
This commit is contained in:
parent
8de9fe7f56
commit
6bc2b27b67
1 changed files with 3 additions and 3 deletions
6
.bashrc
6
.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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue