about summary refs log tree commit homepage
path: root/lib/dtas/process.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-08-25 23:52:24 +0000
committerEric Wong <normalperson@yhbt.net>2013-08-25 23:57:28 +0000
commit5a966a1ec8662d2e0b9035675a770c6f2c739b7d (patch)
tree9b49d65769938a5990ae4f15a9e9695ea3050efc /lib/dtas/process.rb
parentef44f1c957a1bae1f22122276535e384506f5279 (diff)
downloaddtas-5a966a1ec8662d2e0b9035675a770c6f2c739b7d.tar.gz
This should allow us to more easily transfer user-configured
environment variables to helper tools (avprobe/soxi).
Diffstat (limited to 'lib/dtas/process.rb')
-rw-r--r--lib/dtas/process.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/dtas/process.rb b/lib/dtas/process.rb
index 2d7dcb0..3f1dc07 100644
--- a/lib/dtas/process.rb
+++ b/lib/dtas/process.rb
@@ -3,6 +3,7 @@
 # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
 require 'shellwords'
 require 'io/wait'
+require_relative '../dtas'
 module DTAS::Process # :nodoc:
   PIDS = {}
 
@@ -43,7 +44,11 @@ module DTAS::Process # :nodoc:
 
   # this is like backtick, but takes an array instead of a string
   # This will also raise on errors
-  def qx(cmd, opts = {})
+  def qx(env, cmd = {}, opts = {})
+    unless Hash === env
+      cmd, opts = env, cmd
+      env = {}
+    end
     r, w = IO.pipe
     opts = opts.merge(out: w)
     r.binmode
@@ -53,7 +58,7 @@ module DTAS::Process # :nodoc:
       opts[:err] = we
     end
     pid = begin
-      Process.spawn(*cmd, opts)
+      Process.spawn(env, *cmd, opts)
     rescue Errno::EINTR # Ruby bug?
       retry
     end