diff options
| author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-16 02:46:27 +0000 |
|---|---|---|
| committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-16 02:46:27 +0000 |
| commit | b9e0361144da82b25243759c4af5d14a0d996d7a (patch) | |
| tree | 1fd45fd74384420b91f65b1bd7c87dfe28ccce43 | |
| parent | 76507163c13f6c93736ac5346e5c8ea30828ebfb (diff) | |
| download | ruby-b9e0361144da82b25243759c4af5d14a0d996d7a.tar.gz ruby-b9e0361144da82b25243759c4af5d14a0d996d7a.tar.xz ruby-b9e0361144da82b25243759c4af5d14a0d996d7a.zip | |
* lib/require_relative.rb: check require_relative call in eval.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | lib/require_relative.rb | 9 |
2 files changed, 11 insertions, 2 deletions
@@ -1,3 +1,7 @@ +Sat Feb 16 11:45:31 2008 Tanaka Akira <akr@fsij.org> + + * lib/require_relative.rb: check require_relative call in eval. + Sat Feb 16 08:00:01 2008 NARUSE, Yui <naruse@ruby-lang.org> * ruby.c (process_options): set default_external before loading diff --git a/lib/require_relative.rb b/lib/require_relative.rb index 34b094851..e68546f1c 100644 --- a/lib/require_relative.rb +++ b/lib/require_relative.rb @@ -1,6 +1,11 @@ def require_relative(relative_feature) - /:/ =~ caller.first - absolute_feature = File.expand_path(File.join(File.dirname($`), relative_feature)) + c = caller.first + e = c.rindex(/:\d+:in /) + file = $` + if /\A\((.*)\)/ =~ file # eval, etc. + raise LoadError, "require_relative is called in #{$1}" + end + absolute_feature = File.expand_path(File.join(File.dirname(file), relative_feature)) require absolute_feature end |
