diff --git a/lib/irb.rb b/lib/irb.rb index 6e3448d69..82f0a0d1f 100644 --- a/lib/irb.rb +++ b/lib/irb.rb @@ -1513,8 +1513,8 @@ class Binding # # See IRB for more information. def irb(show_code: true) - # Setup IRB with the current file's path and no command line arguments - IRB.setup(source_location[0], argv: []) + # Setup IRB with the current file's path and current session command line arguments + IRB.setup(source_location[0], argv: IRB.conf[:ARGV]) # Create a new workspace using the current binding workspace = IRB::WorkSpace.new(self) # Print the code around the binding if show_code is true diff --git a/lib/irb/init.rb b/lib/irb/init.rb index 66e7b6146..69dda5941 100644 --- a/lib/irb/init.rb +++ b/lib/irb/init.rb @@ -43,9 +43,9 @@ def IRB.version # initialize config def IRB.setup(ap_path, argv: ::ARGV) - IRB.init_config(ap_path) + IRB.init_config(ap_path, argv: argv) IRB.init_error - IRB.parse_opts(argv: argv) + IRB.parse_opts IRB.run_config IRB.load_modules @@ -55,7 +55,7 @@ def IRB.setup(ap_path, argv: ::ARGV) end # @CONF default setting - def IRB.init_config(ap_path) + def IRB.init_config(ap_path, argv: ::ARGV) # class instance variables @TRACER_INITIALIZED = false @@ -68,6 +68,7 @@ def IRB.init_config(ap_path) @CONF[:IRB_NAME] = "irb" @CONF[:IRB_LIB_PATH] = File.dirname(__FILE__) + @CONF[:ARGV] = argv.dup @CONF[:RC] = true @CONF[:LOAD_MODULES] = [] @@ -244,7 +245,8 @@ def IRB.init_error end # option analyzing - def IRB.parse_opts(argv: ::ARGV) + def IRB.parse_opts + argv = @CONF[:ARGV].dup || [] load_path = [] while opt = argv.shift case opt diff --git a/lib/irb/workspace.rb b/lib/irb/workspace.rb index 2bf3d5e0f..fcb5915f8 100644 --- a/lib/irb/workspace.rb +++ b/lib/irb/workspace.rb @@ -112,7 +112,7 @@ def load_commands_to_main main.extend ExtendCommandBundle end - # Evaluate the given +statements+ within the context of this workspace. + # Evaluate the given +statements+ within the context of this workspace. def evaluate(statements, file = __FILE__, line = __LINE__) eval(statements, @binding, file, line) end