#!/bin/bash

set -e

# https://wiki.gnupg.org/AgentForwarding
host=repo@repo.msys2.org
local_gpga_socket="$(gpgconf --list-dirs agent-extra-socket)"
remote_gpga_socket="$(ssh "${host}" -- gpgconf --list-dirs agent-socket)"

if test "${#}" -eq 0
then
	args=()
else
	args=(bash -lc "'\"\$@\"'" bash)
fi
exec ssh -tt -R "${remote_gpga_socket}:${local_gpga_socket}" "${host}" -- "${args[@]}" "${@}"
