From 77b927de0c7c0f0e5e96691f2c9099e307c3e1f3 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 2 Nov 2011 23:00:28 +0000 Subject: [PATCH] mog: remove sysrwloop dependency for "tee" We can do this in a way that's compatible with IO.copy_stream --- bin/mog | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/bin/mog b/bin/mog index 80a1a97..932e766 100755 --- a/bin/mog +++ b/bin/mog @@ -189,10 +189,19 @@ begin # if stdout is pointing to /dev/null, don't bother installing the filter. STDOUT.sync = true - tee_filter = File.stat('/dev/null') == STDOUT.stat ? - nil : Proc.new { |buf| STDOUT.write(buf); buf } + tee_obj = tmp + if File.stat('/dev/null') != STDOUT.stat + tee_obj = lambda do |buf| + rv = nil + [ STDOUT, tmp ].each { |io| rv = io.write(buf) } + rv + end + def tee_obj.write(buf) + self[buf] + end + end begin - sysrwloop(STDIN, tmp, tee_filter) + copy_stream(STDIN, tee_obj) store_file_retry(mg, key, cfg[:class], tmp.path) ensure tmp.close! -- 2.11.4.GIT