[前][次][番号順一覧][スレッド一覧]

ruby-changes:58208

From: takkanm <ko1@a...>
Date: Fri, 11 Oct 2019 09:33:51 +0900 (JST)
Subject: [ruby-changes:58208] 87958520f3 (master): set real path to __FILE__ and __dir__ in Binding#irb

https://git.ruby-lang.org/ruby.git/commit/?id=87958520f3

From 87958520f3fd7fdec18c3508888b3d2a4e5c27a4 Mon Sep 17 00:00:00 2001
From: takkanm <takkanm@g...>
Date: Tue, 19 Jun 2018 20:49:09 +0900
Subject: set real path to __FILE__ and __dir__ in Binding#irb

When reading Binding#irb, the file of the calling source is reflected in __FILE__ and __dir__.

diff --git a/lib/irb.rb b/lib/irb.rb
index a41d4e1..522b53f 100644
--- a/lib/irb.rb
+++ b/lib/irb.rb
@@ -850,6 +850,8 @@ class Binding https://github.com/ruby/ruby/blob/trunk/lib/irb.rb#L850
     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
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]