examples/splice-tee.rb in io_splice-1.0.0 vs examples/splice-tee.rb in io_splice-2.0.0

- old
+ new

@@ -9,24 +9,20 @@ dest = ARGV.shift or abort usage $stdin.stat.pipe? or abort "stdin must be a pipe" $stdout.stat.pipe? or abort "stdout must be a pipe" dest = File.open(dest, 'wb') -out_fd = dest.fileno -stdin_fd = $stdin.fileno -stdout_fd = $stdout.fileno - begin nread = begin # "copy" data from stdin to stdout, without consuming stdin - IO.tee(stdin_fd, stdout_fd, IO::Splice::PIPE_CAPA, 0) + IO.tee($stdin, $stdout, IO::Splice::PIPE_CAPA, 0) rescue EOFError break end # sends data to the file, consumes stdin - nwritten = IO.splice(stdin_fd, nil, out_fd, nil, nread, 0) + nwritten = IO.splice($stdin, nil, dest, nil, nread, 0) nwritten == nread or abort "short splice to file: #{nwritten} != #{nread}" end while true