nobu.nokada / softhome.net wrote:
> Hi,
> 
> It looks position mismatch between stdio and IO descriptor.
> Although this would be a bug, try with #seek before #dup.
> 

OK;

#!/bin/ruby -w
#Hello cat
#Hello dog
#hello canary

puts DATA.gets  #-> one               Ok, as expected.
puts DATA.gets  #-> two               Ok, as expected.

DATA.seek(0, IO::SEEK_CUR)
a=DATA.dup
puts a.gets     #-> three             Yes!
a.rewind        #                     Try rewinding...
puts a.gets     #-> #!/bin/ruby -w    Yes!

DATA.seek(0, IO::SEEK_CUR)
b=DATA.dup
puts b.gets     #-> three             Yes!
b.rewind        #                     Rewind...
puts b.gets     #-> #!/bin/ruby -w    As expected

So as you suggested, the first part works fine with the sync
I'll leave it with you then :)

Andrew Walrond