On Tue, Oct 24, 2023 at 5:21 PM Werner Koch <w...@gnupg.org> wrote: > encrypted-to-me-p.sh > --8<---------------cut here---------------start------------->8--- > #/bin/sh > gpg -d --status-fd 1 -o /dev/null 2>/dev/null "$1" | awk ' > $1=="[GNUPG:]" && $2=="ENC_TO" && $3=="BEF6EFD38FE8DCA0" {print $1; exit 0}' > --8<---------------cut here---------------end--------------->8---
Thank you! I modified that a bit, to make it more readable to me and fix a little bug: The second `$1` doesn’t expand to the file name. Also, I had to pass `--pinentry-mode cancel`. Otherwise it would ask me for the PIN of my smartcard. See below for my version. What I don’t like is the `2>/dev/null` because that may mask actual error messages. I specified `--quiet`. That works to some extend, but I still get: gpg: decryption failed: No secret key I wonder how to get rid of that. My version: #/bin/sh filename=$1 enc_sub_key=04FDF78D1679DD94 gpg --decrypt \ --pinentry-mode cancel \ --status-fd 1 \ --quiet \ --output /dev/null "$1" | awk -v filename="$filename" \ -v enc_sub_key="$enc_sub_key" \ ' $1=="[GNUPG:]" && $2=="ENC_TO" && $3==enc_sub_key { print filename exit 0 }' _______________________________________________ Gnupg-users mailing list Gnupg-users@gnupg.org https://lists.gnupg.org/mailman/listinfo/gnupg-users