15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/bookbinder/sheller.rb', line 15
def run_command(*command)
out, err =
if Hash === command.last
command.last.values_at(:out, :err)
else
[DevNull.new, DevNull.new]
end
env_vars, executable =
if Hash === command.first
command[0..1]
else
[{}, command[0]]
end
exit_status = nil
Open3.popen3(env_vars, executable) do |stdin, stdout, stderr, wait_thr|
t = Thread.new do
stdout.each do |line|
out.puts(line)
end
end
stderr.each do |line|
err.puts(line)
end
t.join
exit_status = wait_thr.value
end
exit_status
end
|