From b9c97b55719c6715d15d16d88475a457bc37f22c Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Fri, 20 Oct 2006 06:02:46 +0000 Subject: [PATCH] Exit if gpg-agent is not running. --- examples/genkey.rb | 5 +++++ examples/roundtrip.rb | 5 +++++ examples/sign.rb | 9 +++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/examples/genkey.rb b/examples/genkey.rb index 4b9b513..909802c 100755 --- a/examples/genkey.rb +++ b/examples/genkey.rb @@ -19,6 +19,11 @@ require 'gpgme' # puts # end +unless ENV['GPG_AGENT_INFO'] + $stderr.puts("gpg-agent is not running. See the comment in #{$0}.") + exit(1) +end + unless ENV['GNUPGHOME'] $stderr.write('As GNUPGHOME is not set, the generated key pair will be stored into *your* keyring. Really proceed? (y/N) ') $stderr.flush diff --git a/examples/roundtrip.rb b/examples/roundtrip.rb index 0677c79..e4a34d8 100755 --- a/examples/roundtrip.rb +++ b/examples/roundtrip.rb @@ -19,6 +19,11 @@ require 'gpgme' # puts # end +unless ENV['GPG_AGENT_INFO'] + $stderr.puts("gpg-agent is not running. See the comment in #{$0}.") + exit(1) +end + plain = 'test test test' puts("Plaintext:\n#{plain}") diff --git a/examples/sign.rb b/examples/sign.rb index 2987057..729f13e 100755 --- a/examples/sign.rb +++ b/examples/sign.rb @@ -19,6 +19,11 @@ require 'gpgme' # puts # end +unless ENV['GPG_AGENT_INFO'] + $stderr.puts("gpg-agent is not running. See the comment in #{$0}.") + exit(1) +end + GPGME::sign('test test test', $stdout, {:mode => GPGME::SIG_MODE_CLEAR, - # :passphrase_callback => method(:passfunc) - }) + # :passphrase_callback => method(:passfunc) + })