diff options
| author | manga_osyo <manga.osyo@gmail.com> | 2021-08-25 21:56:49 +0900 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2021-09-06 07:05:52 +0900 |
| commit | 97a569c648acf489c9fd5602cc4ecc8a012bb07b (patch) | |
| tree | 0b85be9b74012cca7136e1abb27124f8857263d7 | |
| parent | 2a4bacce8c3b21ad2283f3588573f37c671152d2 (diff) | |
[ruby/reline] Memoize path of `.inputrc` [Ref #319]
When `ENV["HOME"] = "foo"` on irb, an exception is raised when retrieving the path of `.inputrc`.
Memoize the path of `.inputrc` and don't get the path after the second time.
https://github.com/ruby/reline/commit/7b90b16165
| -rw-r--r-- | lib/reline/config.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/reline/config.rb b/lib/reline/config.rb index ee73143e0f..f970bccee7 100644 --- a/lib/reline/config.rb +++ b/lib/reline/config.rb @@ -130,8 +130,12 @@ class Reline::Config return home_rc_path end + private def default_inputrc_path + @default_inputrc_path ||= inputrc_path + end + def read(file = nil) - file ||= inputrc_path + file ||= default_inputrc_path begin if file.respond_to?(:readlines) lines = file.readlines |
