Skip to content

Commit 81ca5b4

Browse files
committed
Slightly different implementation
1 parent ff3f758 commit 81ca5b4

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

docs/wsl-ssh-agent-relay

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ usage() {
5555
log ""
5656
log " -v|--verbose verbose mode"
5757
log ""
58-
log " -c|--no-com-test Continue running regardless failed communication test."
59-
log " Use with start and foreground commands when ssh agent"
60-
log " is not running or ready yet."
58+
log " -s|--skip-test skip ssh-agent communication test"
6159
log ""
6260
log " COMMAND: start, stop, foreground"
6361
}
@@ -77,16 +75,16 @@ main() {
7775

7876
POSITIONAL=()
7977
VERBOSE=""
80-
NO_COM_TEST=""
78+
SKIP_SSH_TEST=""
8179
while (($# > 0)); do
8280
case "$1" in
8381
-v | --verbose)
8482
VERBOSE="ENABLED"
8583
shift # shift once since flags have no values
8684
;;
8785

88-
-c | --no-com-test)
89-
NO_COM_TEST="TRUE"
86+
-s | --skip-test)
87+
SKIP_SSH_TEST="TRUE"
9088
shift
9189
;;
9290

@@ -168,21 +166,13 @@ relay() {
168166
fi
169167
log "Relay is running with PID: ${SOCAT_WSL_AGENT_SSH_PID}"
170168

171-
log -n "Polling remote ssh-agent..."
172-
SSH_AUTH_SOCK="${WSL_AGENT_SSH_SOCK}" ssh-add -L >/dev/null 2>&1
173-
status=$?
174-
if [[ "$status" != 0 ]]; then
175-
log "[$status] Failure communicating with ssh-agent"
176-
if [[ -n "$NO_COM_TEST" ]]; then
177-
log "Continuing despite the failed communication test."
178-
else
179-
die
180-
fi
181-
else
169+
if [[ -z "$SKIP_SSH_TEST" ]]; then
170+
log -n "Polling remote ssh-agent..."
171+
SSH_AUTH_SOCK="${WSL_AGENT_SSH_SOCK}" ssh-add -L >/dev/null 2>&1 || die "[$?] Failure communicating with ssh-agent"
182172
log "OK"
183173
fi
184174

185-
# Everything checks, we are ready for actions
175+
# Everything necessary checks, we are ready for actions
186176
log "Entering wait..."
187177
wait ${SOCAT_WSL_AGENT_SSH_PID}
188178
}

0 commit comments

Comments
 (0)