#!/bin/sh

set -eu
[ -n "${DEBUG:-}" ] && set -x

# shellcheck disable=SC2155
export GPG_TTY="$(tty)"

gpg-connect-agent KILLAGENT /bye >/dev/null 2>&1
gpg-connect-agent UPDATESTARTUPTTY /bye >/dev/null 2>&1

# echo "export GPG_TTY='${GPG_TTY-}'"
# echo "export SSH_AUTH_SOCK='$(gpgconf --list-dirs agent-ssh-socket)'"

echo "export GPG_TTY=\"${GPG_TTY}\""
# shellcheck disable=SC2312
echo "export SSH_AUTH_SOCK=\"$(gpgconf --list-dirs agent-ssh-socket)\""

{ set +x; } 2>/dev/null
