diff --git a/ChangeLog b/ChangeLog index a62145d4fc..a8665e2d88 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Sep 8 15:01:19 2015 Shugo Maeda + + * lib/net/ftp.rb (list): fetch all the lines before yielding a block + to allow other commands in the block. [Feature #11454] + Patched by Srikanth Shreenivas. + Tue Sep 8 12:05:00 2015 NAKAMURA Usaku * win32/win32.c (rb_w32_read_reparse_point): return correct required diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb index 3eec86ae99..724f4b85bd 100644 --- a/lib/net/ftp.rb +++ b/lib/net/ftp.rb @@ -755,15 +755,14 @@ module Net args.each do |arg| cmd = "#{cmd} #{arg}" end - if block - retrlines(cmd, &block) - else - lines = [] - retrlines(cmd) do |line| - lines << line - end - return lines + lines = [] + retrlines(cmd) do |line| + lines << line end + if block + lines.each(&block) + end + return lines end alias ls list alias dir list diff --git a/test/net/ftp/test_ftp.rb b/test/net/ftp/test_ftp.rb index 618a9da287..ad8ef5aa37 100644 --- a/test/net/ftp/test_ftp.rb +++ b/test/net/ftp/test_ftp.rb @@ -741,6 +741,146 @@ class FTPTest < Test::Unit::TestCase end end + def test_retrlines + commands = [] + text_data = <