Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open3.popen3 treats string command differently than MRI #2767

Closed
myronmarston opened this Issue Mar 27, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@myronmarston
Copy link

myronmarston commented Mar 27, 2015

Given open3_bug.rb:

require 'shellwords'
require 'open3'

command = "ruby -e 'puts ARGV.inspect' #{'a[1:1]'.shellescape}"
puts `#{command}`

Open3.popen3(command) do |_, stdout, stderr|
  puts stdout.read
  puts stderr.read
end

Notice the different output on JRuby compared to MRI 1.8.7 and 2.2 (suggesting that MRI has always behaved this way):

➜ chruby 1.8.7
➜ ruby -v open3_bug.rb
ruby 1.8.7 (2013-12-22 patchlevel 375) [i686-darwin12.5.0]
["a[1:1]"]
["a[1:1]"]

➜ chruby 2.2
➜ ruby -v open3_bug.rb
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin12.0]
["a[1:1]"]
["a[1:1]"]
➜ chruby jruby
➜ ruby -v open3_bug.rb
jruby 1.7.8 (1.9.3p392) 2013-11-14 0ce429e on Java HotSpot(TM) 64-Bit Server VM 1.6.0_65-b14-462-11M4609 [darwin-x86_64]
["a[1:1]"]
["a\\[1:1\\]"]

The escape characters are treated as part of the argument itself when it gets back in ruby on JRuby but not on MRI.

@headius

This comment has been minimized.

Copy link
Member

headius commented Mar 29, 2015

Works as expected in JRuby 9000, which has completely reimplemented process spawning.

@headius headius closed this Mar 29, 2015

@headius headius added this to the 9.0.0.0.pre2 milestone Mar 29, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.