diff options
-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! |