Repository navigation
Respect parent command line arguments in nested IRB scopes - #848
Closed
nunosilva800 wants to merge 3 commits into
Closed
nunosilva800 wants to merge 3 commits into
nunosilva800 wants to merge 3 commits into
Conversation
nunosilva800
commented
Jan 31, 2024
| # option analyzing | ||
| def IRB.parse_opts(argv: ::ARGV) | ||
| def IRB.parse_opts | ||
| argv = @CONF[:ARGV].dup || [] |
Contributor
Author
nunosilva800
force-pushed
the
625-irbrc-file-loaded-always
branch
from
January 31, 2024 12:57
d1e2203 to
d735dac
Compare
nunosilva800
commented
Jan 31, 2024
Comment on lines
+1516
to
+1517
| # Setup IRB with the current file's path and current session command line arguments | ||
| IRB.setup(source_location[0], argv: IRB.conf[:ARGV]) |
Contributor
Author
There was a problem hiding this comment.
Don't really know how to test this, other than manually steps:
$ mkdir -p tmp
$ echo "puts 'irbrc file loaded'" > tmp/.irbrc
$ bundle exec rake install
$ cd tmp && echo "binding.irb" | irb -f && cd ..Before:
Switch to inspect mode.
binding.irb
irbrc file loaded
Switch to inspect mode.
nil
After:
Switch to inspect mode.
binding.irb
Switch to inspect mode.
nil
I thought about doing this test:
def test_new_session_inherits_parent_config
write_rc <<~RUBY
puts 'irbrc file loaded'
RUBY
write_ruby <<~'RUBY'
require 'irb'
IRB.start
RUBY
output = run_ruby_file(["-f"]) do
type "binding.irb"
type "exit!"
type "exit!"
end
refute output.include?("irbrc file loaded")
endAnd change the helper method ruby_ruby_file to:
def run_ruby_file(cmd_args=[], &block)
cmd = [EnvUtil.rubybin, "-I", LIB, @ruby_file.to_path] + cmd_argsBut the test times-out. I think it's because safe_gets or writing to the command in PTY.spawn is not working this way :/
Contributor
Author
|
Closing in favour of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
binding.irbis called, the new session is setup without command line arguments:irb/lib/irb.rb
Lines 1516 to 1517 in a641746
This means that the child session does not respect the parent command line arguments.
Therefore when using
$ irb -f(to ignore RC file), and opening a child session withbiding.irb, the new session will load the RC file (if it exists).See more in:
The solution I present here is to hold a copy of ARGV in
@CONF, and use that to setup child sessions.Closes #625