about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-11-02 23:00:28 +0000
committerEric Wong <normalperson@yhbt.net>2011-11-02 23:00:28 +0000
commit77b927de0c7c0f0e5e96691f2c9099e307c3e1f3 (patch)
tree0214b0d8847cacfd0c4a5de461084af2e26f78b1
parent100fcbe4b368cd6510e65af5b773ab9d70ef42d6 (diff)
downloadmogilefs-client-77b927de0c7c0f0e5e96691f2c9099e307c3e1f3.tar.gz
We can do this in a way that's compatible with IO.copy_stream
-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!