diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-21 07:00:58 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-21 07:00:58 +0000 |
commit | 3d9453994c965abff8851d008a01b40153ffee77 (patch) | |
tree | 84b4778409112ee0f17e82f004b814abb36a744b /lib | |
parent | b6d97cc9a8496339df5055131cfbca21c5cb9f8b (diff) | |
download | ruby-3d9453994c965abff8851d008a01b40153ffee77.tar.gz |
lib/open3.rb: accept IO-like object for :stdin_data argument.
Open3.capture3, Open3.capture2, Open3.capture2e accepts
IO-like object for :stdin_data argument.
[ruby-core:80936] [Feature #13527] proposed by janko.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/open3.rb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/open3.rb b/lib/open3.rb index 5ff1012b70..2bbead2951 100644 --- a/lib/open3.rb +++ b/lib/open3.rb @@ -264,7 +264,11 @@ module Open3 out_reader = Thread.new { o.read } err_reader = Thread.new { e.read } begin - i.write stdin_data + if stdin_data.respond_to? :readpartial + IO.copy_stream(stdin_data, i) + else + i.write stdin_data + end rescue Errno::EPIPE end i.close @@ -311,7 +315,11 @@ module Open3 out_reader = Thread.new { o.read } if stdin_data begin - i.write stdin_data + if stdin_data.respond_to? :readpartial + IO.copy_stream(stdin_data, i) + else + i.write stdin_data + end rescue Errno::EPIPE end end @@ -346,7 +354,11 @@ module Open3 outerr_reader = Thread.new { oe.read } if stdin_data begin - i.write stdin_data + if stdin_data.respond_to? :readpartial + IO.copy_stream(stdin_data, i) + else + i.write stdin_data + end rescue Errno::EPIPE end end |