IO.popen doesn't convert CRLF to LF on Windows in default mode
--------------------------------------------------------------

                 Key: JRUBY-4814
                 URL: http://jira.codehaus.org/browse/JRUBY-4814
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules, Windows
    Affects Versions: JRuby 1.5
         Environment: Windows
            Reporter: Vladimir Sizikov


jruby -e "IO.popen('echo foo', 'r') do |io| p io.gets; end" ==> "foo\r\n"

while

ruby -e "IO.popen('echo foo', 'r') do |io| p io.gets; end" ==> "foo\n"

The problem lies in ChannelStream's maybeWrapWithLineEndingWrapper:
{code}
private static Stream maybeWrapWithLineEndingWrapper(Stream stream, ModeFlags 
modes) {
    if (Platform.IS_WINDOWS && stream.getDescriptor().getChannel() instanceof 
FileChannel
            && !modes.isBinary()) {
        return new CRLFStreamWrapper(stream);
    }
    return stream;
}
{code}

Here, the CRLFStreamWrapper is only set for FileChannels, which is not true in 
case of popen.
Simple removal of that instanceof check leads to some other rubyspec failures, 
so the fix is not as simple as that. :)

Note that this bug causes one RubySpec failure:
{noformat}
1)
IO.popen reads from a read-only pipe FAILED
Expected "foo\r\n"
 to equal "foo\n"

D:/work/jruby-dev/rubyspec.git/core/io/popen_spec.rb:6
D:/work/jruby-dev/rubyspec.git/core/io/popen_spec.rb:5
D:/work/jruby-dev/rubyspec.git/core/io/popen_spec.rb:3
D:/work/jruby-dev/rubyspec.git/core/io/popen_spec.rb:56:in `load'
D:/work/jruby-dev/mspec.git/bin/mspec-ci:8
{noformat}


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to