Recognise these with an ad-hoc pattern on the command line arguments.
When they occur, save stdin to a temporary file.
We can't do this generally, because stdin might be some thing that
gpg's caller doesn't expect gpg to eat.
When we do this saving, print the size in bytes of the input file.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
for attempt in '' ' ' exec; do
for attempt in '' ' ' exec; do
+case "$*" in
+*"
+--batch
+--import")
+ # ^ apt-key's invocation
+ if [ "x$stdin_tmp" = x ]; then
+ stdin_tmp="$GNUPGHOME"/dgit-stdin-tmp
+ cat >$stdin_tmp
+ stdin_tmp_bytes=$(wc -c <$stdin_tmp)
+ fi
+ exec <$stdin_tmp
+ ;;
+esac
+
set +e
$attempt \
$DGIT_TEST_REAL_GPG \
set +e
$attempt \
$DGIT_TEST_REAL_GPG \
if [ $rc != 2 ]; then exit $rc; fi
if [ $rc != 2 ]; then exit $rc; fi
-echo >&2 "WARNING - GNUPG FAILED $rc - STUNT GNUPG $attempt $*"
+echo >&2 "WARNING - GNUPG FAILED $rc - STUNT GNUPG $attempt $stdin_tmp_bytes $*"
sh -ec '
if [ "x$DGIT_GNUPG_STUNT_ERRLOG" != x ]; then
sh -ec '
if [ "x$DGIT_GNUPG_STUNT_ERRLOG" != x ]; then
fi
exec >/dev/tty
printf "%s\n" "$*"
fi
exec >/dev/tty
printf "%s\n" "$*"
-' x "GNUPG WRAPPER - TROUBLE - $HOME $GNUPGHOME - FAILED $rc $attempt $*"
+' x "GNUPG WRAPPER - TROUBLE - $HOME $GNUPGHOME - FAILED $rc $attempt $stdin_tmp_bytes $*"