Skip to content

File.open w/ File::RDWR should write \r\n but gets should read as \n after rewind on windows #3738

@enebo

Description

@enebo

Environment

Broken in different ways on JRuby 1.7.24 and 9.0.5.0.

Expected Behavior

For the following script:

file = "temptemp"

File.open(file, "w") {}
File.open(file, File::RDWR) do |f|
  f.puts("writing")  # writes "writing\r\n"
  f.flush            # force to disk
  gets               # do not continue until you can verify it was written right
  f.rewind           # backup
  p f.gets           # read it but it should be "writing\n"
end
File.unlink(file)

The comments dictate how it should behave.

Actual Behavior

On JRuby 1.7.24 it will write "writing\r\n" but it will read "writing\r\n". instead of "writing\n".
On JRuby 9.0.5.0 it wil write "writing\n" instead of "writing\r\n" but it will read "writing\n".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions