Use spawn() instead of system().
authorZac Medico <zmedico@gentoo.org>
Wed, 11 Jun 2008 03:37:55 +0000 (03:37 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 11 Jun 2008 03:37:55 +0000 (03:37 -0000)
svn path=/main/trunk/; revision=10642

bin/dispatch-conf

index ec19e1e4d45d607a5e5af477eba7daa13e42a4c4..8ae055565b8365caa662a5f6fd876d176d6cb3c4 100755 (executable)
@@ -217,10 +217,12 @@ class dispatch:
             while 1:
                 clear_screen()
                 if show_new_diff:
-                    os.system((self.options['diff']) % (conf['new'], mrgconf))
+                    cmd = self.options['diff'] % (conf['new'], mrgconf)
+                    spawn_shell(cmd)
                     show_new_diff = 0
                 else:
-                    os.system((self.options['diff']) % (conf['current'], newconf))
+                    cmd = self.options['diff'] % (conf['current'], newconf)
+                    spawn_shell(cmd)
 
                 print
                 print '>> (%i of %i) -- %s' % (count, len(confs), conf ['current'])
@@ -392,6 +394,20 @@ def clear_screen():
         pass
     os.system("clear 2>/dev/null")
 
+from portage.process import find_binary, spawn
+shell = os.environ.get("SHELL")
+if not shell or not os.access(shell, os.EX_OK):
+    shell = find_binary("sh")
+
+def spawn_shell(cmd):
+    if shell:
+        spawn([shell, "-c", cmd], env=os.environ,
+            fd_pipes = {  0 : sys.stdin.fileno(),
+                          1 : sys.stdout.fileno(),
+                          2 : sys.stderr.fileno()})
+    else:
+        os.system(cmd)
+
 # run
 d = dispatch ()