Comments (6)
Replacing the bottom code of lib/reline.rb with the following seems to work on Windows, but not sure about other OS's and using tty to determine IO type...
Reline::IOGate = begin
t = if Reline::Core::IS_WINDOWS
require 'reline/windows'
Reline::Windows
else
require 'reline/ansi'
Reline::ANSI
end
require 'reline/general_io'
STDOUT.tty? && STDIN.tty? ? t : Reline::GeneralIO
end
Reline.input = $stdin if Reline::IOGate == Reline::GeneralIO
FYI, with a few patches, byebug passes on Windows using Reline.
from reline.
That sounds like a snippet we could perfectly add to byebug's test helper, right?
Would you like to open a PR there? We shouldn't merge it straight away since we'll need to verify that the real user experience is unchanged, but a green CI would be a great starting point.
Not sure if there's anything to be changed in reline
? Certainly the "testing mode" could be easier to setup, but this is something!
from reline.
That sounds like a snippet we could perfectly add to byebug's test helper, right?
Is the test helper loaded when Open3 is used? Don't recall...
need to verify that the real user experience is unchanged
I'm not sure what the benchmark is for a 'correct' user experience.
from reline.
No benchmark, I meant that I'll use byebug
with reline
for a bit and verify that there's no obvious user visible changes/gotchas/bugs.
Is the test helper loaded when Open3 is used? Don't recall...
I don't think so, but we can load the snippet when needed, I think we do something similar with a simplecov
helper file to make sure that coverage is tracked inside subprocesses.
Anyways, this is getting out of topic here, let's move the discussion to deivid-rodriguez/byebug#510.
from reline.
Hi guys, your issue is the only one result google gives me about this:
$ ruby -e "p STDOUT.pos"
17800074
$ ruby -ropen3 -e "p Open3.capture2e 'ruby -e \"p STDOUT.pos\"'"
["-e:1:in `pos': Illegal seek @ rb_io_tell - <STDOUT> (Errno::ESPIPE)\n\tfrom -e:1:in `<main>'\n", #<Process::Status: pid 83602 exit 1>]
I face this issue in tests that launch my gem bin/ executable. It's the same in Ruby 2.3 .. 3.0
UPD: the same with backticks:
$ irb
irb(main):001:0> `ruby -e "p STDOUT.pos"`
-e:1:in `pos': Illegal seek @ rb_io_tell - <STDOUT> (Errno::ESPIPE)
from -e:1:in `<main>'
and with IO.popen
from reline.
I tried to reuse the #4796 patch. With no success.
$ cat use_ext_readline.rb
require "readline.so"
ReadlineSo = Readline
Object.send(:remove_const, :Readline) if Object.const_defined?(:Readline)
Object.const_set(:Readline, ReadlineSo)
$ ruby -ropen3 -e "p Open3.capture2e 'ruby -rreline -r./use_ext_readline.rb -e \"p STDOUT.pos\"'"
["-e:1:in `pos': Illegal seek @ rb_io_tell - <STDOUT> (Errno::ESPIPE)\n\tfrom -e:1:in `<main>'\n", #<Process::Status: pid 85906 exit 1>]
$ cat use_lib_reline.rb
Reline.send(:remove_const, 'IOGate') if Reline.const_defined?('IOGate')
Reline.const_set('IOGate', Reline::GeneralIO)
Reline.send(:core).config.instance_variable_set(:@test_mode, true)
Reline.send(:core).config.reset
Object.send(:remove_const, :Readline) if Object.const_defined?(:Readline)
Object.const_set(:Readline, Reline)
$ ruby -ropen3 -e "p Open3.capture2e 'ruby -rreline -r./use_lib_reline.rb -e \"p STDOUT.pos\"'"
["-e:1:in `pos': Illegal seek @ rb_io_tell - <STDOUT> (Errno::ESPIPE)\n\tfrom -e:1:in `<main>'\n", #<Process::Status: pid 85916 exit 1>]
ruby 3.0.1
from reline.
Related Issues (20)
- Completion dialog disappears while moving completion list to candidates that ends with `=`
- Inputrc mode conditions not handled
- Reline crash with `C-v` `C-k` and any alphabet
- Continue implement bracketed paste mode HOT 1
- Wrong inputrc loading order HOT 1
- newline not honored in Reline.readline("\nMy Prompt: ") HOT 1
- Support multiline input in nomultiline mode `Reline.readline`
- When used inside Emacs with Reline, input is echoed HOT 3
- Cursor offset with show-mode-in-prompt string HOT 2
- Don't enable test mode by TERM=dumb HOT 3
- reline/line_editor.rb:367:in `==': stack level too deep (SystemStackError) HOT 6
- no implicit conversion of Array into Integer (TypeError) HOT 4
- Add a timeout to `cursor_pos` and warn if terminal does not respond to cursor position query HOT 2
- Upward navigation through completion results not working as expected HOT 4
- Text echoes after using backtick on Windows 11 command prompt/powershell HOT 4
- Some operations throwing the exception reline/ansi.rb:246:in `winsize': Operation not supported by device - <STDIN> (Errno::ENODEV) HOT 2
- `editing-mode` rewinds after input confirmation
- Reline does not support convert-meta HOT 1
- Crash when Kernel#loop is redefined HOT 4
- Sorbet complains about Reline::ANSI HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reline.