aboutsummaryrefslogtreecommitdiffstats
path: root/tool
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2023-10-17 17:57:39 -0700
committerGitHub <noreply@github.com>2023-10-17 17:57:39 -0700
commit6c46ccf226bc6440743b51af713864c062eba27f (patch)
tree3f69d77ba463fb0c64b4732524d99f6eec2bd6f4 /tool
parent7a3a98e2be69fd3fa68e6ee1afa43c3160f22254 (diff)
downloadruby-6c46ccf226bc6440743b51af713864c062eba27f.tar.gz
Prefer RbConfig.ruby over the 3.times fallback (#8691)
It seems saner to use RbConfig.ruby than using ruby in a random ancestor directory.
Diffstat (limited to 'tool')
-rw-r--r--tool/lib/envutil.rb29
1 files changed, 14 insertions, 15 deletions
diff --git a/tool/lib/envutil.rb b/tool/lib/envutil.rb
index 3fcded4162..1ca76d17a7 100644
--- a/tool/lib/envutil.rb
+++ b/tool/lib/envutil.rb
@@ -15,23 +15,22 @@ end
module EnvUtil
def rubybin
if ruby = ENV["RUBY"]
- return ruby
- end
- ruby = "ruby"
- exeext = RbConfig::CONFIG["EXEEXT"]
- rubyexe = (ruby + exeext if exeext and !exeext.empty?)
- 3.times do
- if File.exist? ruby and File.executable? ruby and !File.directory? ruby
- return File.expand_path(ruby)
- end
- if rubyexe and File.exist? rubyexe and File.executable? rubyexe
- return File.expand_path(rubyexe)
- end
- ruby = File.join("..", ruby)
- end
- if defined?(RbConfig.ruby)
+ ruby
+ elsif defined?(RbConfig.ruby)
RbConfig.ruby
else
+ ruby = "ruby"
+ exeext = RbConfig::CONFIG["EXEEXT"]
+ rubyexe = (ruby + exeext if exeext and !exeext.empty?)
+ 3.times do
+ if File.exist? ruby and File.executable? ruby and !File.directory? ruby
+ return File.expand_path(ruby)
+ end
+ if rubyexe and File.exist? rubyexe and File.executable? rubyexe
+ return File.expand_path(rubyexe)
+ end
+ ruby = File.join("..", ruby)
+ end
"ruby"
end
end