diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-11-02 23:00:28 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-11-02 23:00:28 +0000 |
commit | 77b927de0c7c0f0e5e96691f2c9099e307c3e1f3 (patch) | |
tree | 0214b0d8847cacfd0c4a5de461084af2e26f78b1 | |
parent | 100fcbe4b368cd6510e65af5b773ab9d70ef42d6 (diff) | |
download | mogilefs-client-77b927de0c7c0f0e5e96691f2c9099e307c3e1f3.tar.gz |
We can do this in a way that's compatible with IO.copy_stream
-rwxr-xr-x | bin/mog | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -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! |