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

Issues sending input to executed commands using IRB on OS X #3783

Open
preetpalS opened this issue Apr 7, 2016 · 5 comments
Open

Issues sending input to executed commands using IRB on OS X #3783

preetpalS opened this issue Apr 7, 2016 · 5 comments

Comments

@preetpalS
Copy link

The following line of code illustrates the issue:

system 'ruby -e "puts \"What is your name?\"; puts \"Hi #{gets.strip}, nice to meet you.\""'

This line of code will not run on 64-bit JRuby on Windows but will run on 64-bit Ruby MRI on Windows (verified on version 2.3.0 but I am confident it works on version 2.2.3 as well as earlier versions). Trying to execute it, gives the following error: uninitialized constant What (NameError).

This line of code will work on OS X (El Capitan, JRuby 9.0.5.0), but NOT when executed through irb (pressing ENTER on keyboard result in ^M being printed in terminal (on MRI, pressing ENTER on keyboard sends the input to the command being executed by Kernel#system)).

Environment

My OS X environment

$ java -version
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
$ uname -a
Darwin pss-MacBook-Air 15.4.0 Darwin Kernel Version 15.4.0: Fri Feb 26 22:08:05 PST 2016; root:xnu-3248.40.184~3/RELEASE_X86_64 x86_64
$ jruby -v
jruby 9.0.5.0 (2.2.3) 2016-01-26 7bee00d Java HotSpot(TM) 64-Bit Server VM 25.77-b03 on 1.8.0_77-b03 +jit [darwin-x86_64]
$ ruby -v
jruby 9.0.5.0 (2.2.3) 2016-01-26 7bee00d Java HotSpot(TM) 64-Bit Server VM 25.77-b03 on 1.8.0_77-b03 +jit [darwin-x86_64]

My Windows environment

C:>java -version
java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)

C:>jruby -v
jruby 9.0.5.0 (2.2.3) 2016-01-26 7bee00d Java HotSpot(TM) 64-Bit Server VM 25.74-b02 on 1.8.0_74-b02 +jit [Windows 10-amd64]

C:>ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32]

C:>ver

Microsoft Windows [Version 10.0.10586]

Expected Behavior

See: https://gist.github.com/preetpalS/2d24c2a10409daac5063d401b39ce798

Actual Behavior

OS X irb

Note the ^M that appear in the example below appear when pressing ENTER on the keyboard.

irb(main):001:0> system 'ruby -e "puts \"What is your name?\"; puts \"Hi #{gets.strip}, nice to meet you.\""' What is your name? Test^M^M^M^M^CIRB::Abort: abort then interrupt! from org/jruby/RubyIO.java:1436:inwrite'
from org/jruby/RubyIO.java:1408:in write' from org/jruby/RubyIO.java:2545:inwrite'
from org/jruby/RubyKernel.java:579:in printf' from org/jruby/RubyKernel.java:1287:inloop'
from org/jruby/RubyKernel.java:1096:in catch' from org/jruby/RubyKernel.java:1096:incatch'
from /Users/preet/.rbenv/versions/jruby-9.0.5.0/bin/irb:13:in <top>' irb(main):002:0> exit

Windows

`C:\test>cat test.rb

system 'ruby -e "puts "What is your name?"; puts "Hi #{gets.strip}, nice to meet you.""'

C:\test>jruby test.rb
-e:1:in `

': uninitialized constant What (NameError)

C:\test>ruby test.rb
What is your name?
Test
Hi Test, nice to meet you.

C:\test>irb
irb(main):001:0> system 'ruby -e "puts "What is your name?"; puts "Hi #{gets.strip}, nice to meet you.""'
What is your name?
Preetpal
Hi Preetpal, nice to meet you.
=> true
irb(main):002:0> exit

C:\test>jirb.bat
irb(main):001:0> system 'ruby -e "puts "What is your name?"; puts "Hi #{gets.strip}, nice to meet you.""'
-e:1:in <main>': uninitialized constant What (NameError) => false irb(main):002:0> exit

@enebo enebo added this to the Invalid or Duplicate milestone Apr 7, 2016
@enebo
Copy link
Member

enebo commented Apr 7, 2016

Duplicate of #3725 We have a plan for this but it is going to be the release after next when we get a new native launcher mjruby into jruby-launcher.

@enebo enebo closed this as completed Apr 7, 2016
@preetpalS
Copy link
Author

There are also issues when trying to run the code using irb on OS X (pressing enter on your keyboard doesn't work to send input to the command you are running via Kernel#system).

@enebo
Copy link
Member

enebo commented Apr 7, 2016

@preetpalS oh sorry I missed the MacOS side of this. These are two different bugs. I will change this one to just be the MacOS behavior since #3725 covers the quoting problem with our binary launcher.

@enebo enebo removed this from the Invalid or Duplicate milestone Apr 7, 2016
@enebo enebo changed the title Issues sending input to commands executed via Kernel#system on 64-bit Windows and in IRB on OS X Issues sending input to executed commands using IRB on OS X Apr 7, 2016
@enebo
Copy link
Member

enebo commented Apr 7, 2016

I only changed the subject line and not the original description. If people read below your original report then they will see that this only covers the input issue and not the quoting issue.

@preetpalS
Copy link
Author

Thanks for revisiting this issue, I apologize for submitting this wall of text as an issue (it's easy to miss the OS X side of the issue).

Were you going to reopen the issue? Also, if preferable, I can remove the portion about windows (the issue is a bit long) in the description.

@enebo enebo reopened this Apr 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants