1
0
Fork 0

Update new-host.sh

main
Mari 5 years ago committed by GitHub
parent ae557a03bc
commit 16f951b6fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      new-host.sh

@ -28,9 +28,15 @@ fi
function getCurrentGithubId() {
local RESULT;
RESULT=$(ssh -o "IdentitiesOnly=yes" -i ~/.ssh/id_ed25519 -T git@github.com </dev/null 2>&1)
[[ $? -ne 255 ]] || { echo "$RESULT" >&2; exit 1; }
USERNAME=$(echo "$RESULT" | sed -n 's/^Hi \([^!]\+\)! You'"'"'ve successfully authenticated, but GitHub does not provide shell access\.$/Successfully authenticated to GitHub as \1/; T; p') || exit 1
set +e
RESULT=$(ssh -o "IdentitiesOnly=yes" -i ~/.ssh/id_ed25519 -T git@github.com </dev/null 2>&1)
if [[ $? -eq 255 ]]; then
echo "$RESULT" >&2
return 1
fi
if ! USERNAME=$(echo "$RESULT" | sed -n 's/^Hi \([^!]\+\)! You'"'"'ve successfully authenticated, but GitHub does not provide shell access\.$/\1/; T; p'); then
return 1
fi
echo "$USERNAME"
[[ -n "$USERNAME" ]];
}

Loading…
Cancel
Save