- if [[ ${+GPG_TTY} -eq 0 && -o interactive ]]
- export GPG_TTY=$(tty)
- if [[ ( -v DISPLAY || -v WAYLAND_DISPLAY ) &&
- ${PINENTRY_USER_DATA/USE_TTY=0} == $PINENTRY_USER_DATA ]]
- export PINENTRY_USER_DATA=USE_TTY=$((
- ${+DISPLAY} + ${+WAYLAND_DISPLAY} == 0))
- # XXX: don't know if gpg-agent supports comments after directives
- # XXX: path could have #
- sed -Ei 's#^([[:space:]]*pinentry-program[[:space:]]).*$#\1'${commands[pinentry]:-/dev/null}'#' \
- ${GNUPGHOME:-~/.gnupg}/gpg-agent.conf
- # XXX: could probably check for changes before doing this to save perf
- gpg-connect-agent RELOADAGENT UPDATESTARTUPTTY /bye >/dev/null 2>&1
- $p && gpg-connect-agent /subst /serverpid \
- "/echo $a pid \${get serverpid} on $GPG_TTY" /bye
+ if [[ ! -v _sev_setup_gpg_forward ]] {
+ if [[ ${+GPG_TTY} -eq 0 && -o interactive ]]
+ export GPG_TTY=$(tty)
+ if [[ ( -v DISPLAY || -v WAYLAND_DISPLAY ) &&
+ ${PINENTRY_USER_DATA/USE_TTY=0} == $PINENTRY_USER_DATA ]]
+ export PINENTRY_USER_DATA=USE_TTY=$((
+ ${+DISPLAY} + ${+WAYLAND_DISPLAY} == 0))
+ # XXX: don't know if gpg-agent supports comments after directives
+ # XXX: path could have #
+ sed -Ei 's#^([[:space:]]*pinentry-program[[:space:]]).*$#\1'${commands[pinentry]:-/dev/null}'#' \
+ ${GNUPGHOME:-~/.gnupg}/gpg-agent.conf
+ # XXX: could check for changes before doing this to save perf
+ gpg-connect-agent RELOADAGENT UPDATESTARTUPTTY /bye >/dev/null 2>&1
+ if {$p} {
+ gpg-connect-agent /subst /serverpid \
+ "/echo pid \${get serverpid} on $GPG_TTY" /bye 2>/dev/null
+ print -nP '%f'
+ }
+ } elif {$p} {
+ print -P '%f'
+ }