Ruby 1.8.1/cygwin: Writing text files (dos mode) broken?

I was recently running some tests before switching to ruby 1.8.1 on cygwin. I
found one problem that currently keeps me from installing ruby 1.8.1:

When writing text files they end up as unix files even though I explicitly
told setup.exe to use dos mode:

f = File.new(“test.txt”,“w”)
f.puts(“Where \n is the CR?”)
f.close

Running above script on ruby 1.8.1 will create test.txt with only 0x0a (LF)
as line delimiter. When using ruby 1.6.8 this correctly creates a dos-like
text file (CR+LF)

My ruby app (a build engine) creates c/cpp headers and resource files to be
used by cl.exe and friends - and some of them won’t accept unix style files.

Maybe someone could verify/comment on that? Did I miss something here? IMHO
line ending conversion should still be transparent to ruby scripts?

ps. Actually I think this is caused by io.c:line 4087 where cygwin_internal()
is used to unconditionally set file IO to binmode!?

PeJaMa@web.de (Marcus Heyking) wrote in message news:2b3b40bb.0403160853.639303b7@posting.google.com

I was recently running some tests before switching to ruby 1.8.1 on cygwin. I
found one problem that currently keeps me from installing ruby 1.8.1:

When writing text files they end up as unix files even though I explicitly
told setup.exe to use dos mode:

f = File.new(“test.txt”,“w”)
f.puts(“Where \n is the CR?”)
f.close

Running above script on ruby 1.8.1 will create test.txt with only 0x0a (LF)
as line delimiter. When using ruby 1.6.8 this correctly creates a dos-like
text file (CR+LF)

My ruby app (a build engine) creates c/cpp headers and resource files to be
used by cl.exe and friends - and some of them won’t accept unix style files.

Maybe someone could verify/comment on that? Did I miss something here? IMHO
line ending conversion should still be transparent to ruby scripts?

ps. Actually I think this is caused by io.c:line 4087 where cygwin_internal()
is used to unconditionally set file IO to binmode!?

when installing cygwin you get the option to select the file type -
unix or msdos - could you have set this and now ruby is correctly
creating unix style files?

paul.rogers@shaw.ca (Paul) wrote in message news:4ee21163.0403161635.22d739f2@posting.google.com

PeJaMa@web.de (Marcus Heyking) wrote in message news:2b3b40bb.0403160853.639303b7@posting.google.com

I was recently running some tests before switching to ruby 1.8.1 on cygwin. I
found one problem that currently keeps me from installing ruby 1.8.1:

When writing text files they end up as unix files even though I explicitly
told setup.exe to use dos mode:

f = File.new(“test.txt”,“w”)
f.puts(“Where \n is the CR?”)
f.close

Running above script on ruby 1.8.1 will create test.txt with only 0x0a (LF)
as line delimiter. When using ruby 1.6.8 this correctly creates a dos-like
text file (CR+LF)

My ruby app (a build engine) creates c/cpp headers and resource files to be
used by cl.exe and friends - and some of them won’t accept unix style files.

Maybe someone could verify/comment on that? Did I miss something here? IMHO
line ending conversion should still be transparent to ruby scripts?

ps. Actually I think this is caused by io.c:line 4087 where cygwin_internal()
is used to unconditionally set file IO to binmode!?

when installing cygwin you get the option to select the file type -
unix or msdos - could you have set this and now ruby is correctly
creating unix style files?

No, I was definitely using dos-mode when I installed cygwin.

As mentioned before - I was already looking a bit further and I assume that
this happens because now (since 1.8.x) all file IO is done in binmode for
cygwin. IMHO this is what prevents the cygwin library from handling line
ending conversion.

If I write a file in C,bash,perl (also just using \n in strings) they
do have DOS lineendings!