1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/ruby/envutil.rb
nobu f5cbe886b6 * eval.c (rb_add_threadswitch_hook): wrapper for unofficial APIs
in Mac OS X port.  the use of them is strongly discouraged.

	* eval.c (rb_remove_threadswitch_hook): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@29326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-23 18:00:46 +00:00

58 lines
1.3 KiB
Ruby

$".replace($" | [File.basename(__FILE__), __FILE__])
module EnvUtil
def rubybin
if ruby = ENV["RUBY"]
return ruby
end
ruby = "ruby"
rubyexe = ruby+".exe"
3.times do
if File.exist? ruby and File.executable? ruby and !File.directory? ruby
return File.expand_path(ruby)
end
if File.exist? rubyexe and File.executable? rubyexe
return File.expand_path(ruby)
end
ruby = File.join("..", ruby)
end
if defined?(RbConfig.ruby)
File.join(
Config::CONFIG["bindir"],
Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"]
)
else
"ruby"
end
end
module_function :rubybin
def verbose_warning
class << (stderr = "")
alias write <<
end
stderr, $stderr, verbose, $VERBOSE = $stderr, stderr, $VERBOSE, true
yield stderr
ensure
stderr, $stderr, $VERBOSE = $stderr, stderr, verbose
return stderr
end
module_function :verbose_warning
end
begin
require 'rbconfig'
rescue LoadError
else
module RbConfig
@ruby = EnvUtil.rubybin
class << self
undef ruby if defined?(ruby)
attr_reader :ruby
end
dir = File.dirname(ruby)
name = File.basename(ruby, CONFIG['EXEEXT'])
CONFIG['bindir'] = dir
CONFIG['ruby_install_name'] = name
CONFIG['RUBY_INSTALL_NAME'] = name
end
end