sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 57d41646e70695921326e9cffe8909649ae42aa7
parent a8b5c6db0587fe4383758dc3400aaab85ad22d8b
Author: William Morgan <wmorgan-sup@masanjin.net>
Date:   Sun, 11 Oct 2009 12:51:15 -0700

crypto: handle gpg commands that invoke curses

GPG commands can invoke curses programs such as console-pinentry, via
gpg-agent. Use BufferManager#shell_out to handle this.

Diffstat:
M lib/sup/crypto.rb | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/lib/sup/crypto.rb b/lib/sup/crypto.rb
@@ -169,10 +169,17 @@ private
     payload.to_s.gsub(/(^|[^\r])\n/, "\\1\r\n").gsub(/^MIME-Version: .*\r\n/, "")
   end
 
-  def run_gpg args
-    cmd = "#{@cmd} #{args} 2> /dev/null"
-    output = `#{cmd}`
-    output
+  def run_gpg args, opts={}
+    cmd = "#{@cmd} #{args}"
+    if opts[:interactive] && BufferManager.instantiated?
+      output_fn = Tempfile.new "redwood.output"
+      output_fn.close
+      cmd += " > #{output_fn.path} 2> /dev/null"
+      BufferManager.shell_out cmd
+      IO.read(output_fn.path) rescue "can't read output"
+    else
+      `#{cmd} 2> /dev/null`
+    end
   end
 end
 end