在 shell 脚本中,我想检查是否gpg-agent
具有有效的缓存凭据。我怎样才能做到这一点?
答案1
在更好的事情出现之前,我已经决定了:
#!/bin/bash
if gpg --batch --output=/dev/null --clearsign /etc/services 2> /dev/null; then
echo "Congratulations! Your GPG credentials are ready."
exit 0
else
echo "gpg-agent does not have valid cached credentials"
exit 2
fi