Skip to content

Commit

Permalink
set real path to __FILE__ and __dir__ in Binding#irb
Browse files Browse the repository at this point in the history
When reading Binding#irb, the file of the calling source is reflected in __FILE__ and __dir__.
  • Loading branch information
takkanm authored and znz committed Oct 11, 2019
1 parent 29c1e9a commit 8795852
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/irb.rb
Expand Up @@ -850,6 +850,8 @@ def irb
IRB.setup(source_location[0], argv: [])
workspace = IRB::WorkSpace.new(self)
STDOUT.print(workspace.code_around_binding)
IRB::Irb.new(workspace).run(IRB.conf)
binding_irb = IRB::Irb.new(workspace)
binding_irb.context.irb_path = File.expand_path(source_location[0])
binding_irb.run(IRB.conf)
end
end

0 comments on commit 8795852

Please sign in to comment.