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

ruby-changes:62163

From: Jeremy <ko1@a...>
Date: Fri, 10 Jul 2020 06:50:00 +0900 (JST)
Subject: [ruby-changes:62163] e1bbb9ea9c (master): Document that Kernel#load will load relative to current directory [ci skip]

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

From e1bbb9ea9ce205320267783960cfb2e9215d5f52 Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@j...>
Date: Thu, 9 Jul 2020 14:47:13 -0700
Subject: Document that Kernel#load will load relative to current directory [ci
 skip]

Update and format the Kernel#load documentation to separate the
three cases (absolute path, explicit relative path, other), and
also document that it raises LoadError on failure.

Fixes [Bug #16988]

diff --git a/load.c b/load.c
index 8569287..b0143b7 100644
--- a/load.c
+++ b/load.c
@@ -682,10 +682,22 @@ rb_load_protect(VALUE fname, int wrap, int *pstate) https://github.com/ruby/ruby/blob/trunk/load.c#L682
  *
  *  Loads and executes the Ruby program in the file _filename_.
  *
- *  If the filename neither resolves to an absolute path nor starts with
- *  './' or '../', the file will be searched for in the library
+ *  If the filename is an absolute path (e.g. starts with '/'), the file
+ *  will be loaded directly using the absolute path.
+ *
+ *  If the filename is an explicit relative path (e.g. starts with './' or
+ *  '../'), the file will be loaded using the relative path from the current
+ *  directory.
+ *
+ *  Otherwise, the file will be searched for in the library
  *  directories listed in <code>$LOAD_PATH</code> (<code>$:</code>).
- *  If the filename starts with './' or '../', resolution is based on Dir.pwd.
+ *  If the file is found in a directory, it will attempt to load the file
+ *  relative to that directory.  If the file is not found in any of the
+ *  directories in <code>$LOAD_PATH</code>, the file will be loaded using
+ *  the relative path from the current directory.
+ *
+ *  If the file doesn't exist when there is an attempt to load it, a
+ *  LoadError will be raised.
  *
  *  If the optional _wrap_ parameter is +true+, the loaded script will
  *  be executed under an anonymous module, protecting the calling
-- 
cgit v0.10.2


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

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