Comment detail

入出力の中継 (Nested Flatten)
Rubyを100%にするためにとりあえず。あまりまじめに書いてません……
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
def pipe(f, g, th=nil)
  while line = g.gets
    f.puts line
  end
  th.exit if th
end

cmd1, cmd2 = ARGV
f1 = IO.popen(cmd1, "r+")
f2 = IO.popen(cmd2, "r+")
begin
  th1 = Thread.new { pipe f1, f2 }
  th2 = Thread.new { pipe f2, f1, th1 }
  th1.join
rescue
end

Index

Feed

Other

Link

Pathtraq

loading...