about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rwxr-xr-xbin/mog15
1 files 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!