
Some things can break in hard to debug ways if users or build scripts set these variables, causing our otherwise quite robust Ruby wrappers to fail. In theory, we could also use `--disable-rubyopt`, but this is not supported in Ruby 1.8 (and we still care about it).
47 lines
1.3 KiB
Bash
Executable File
47 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
# Make sure this shim uses the same Ruby interpreter that is used by Homebrew.
|
|
unset RUBYLIB
|
|
unset RUBYOPT
|
|
exec "$HOMEBREW_RUBY_PATH" -x "$0" "$@"
|
|
#!/usr/bin/env ruby -W0
|
|
|
|
# This script because we support $GIT, $HOMEBREW_SVN, etc. and Xcode-only
|
|
# configurations. Order is careful to be what the user would want.
|
|
|
|
F = File.basename(__FILE__).freeze
|
|
D = File.expand_path(File.dirname(__FILE__)).freeze
|
|
|
|
def exec(*args)
|
|
# prevent fork-bombs
|
|
arg0 = args.first
|
|
return if arg0 =~ /^#{F}/i || File.expand_path(arg0) == File.expand_path(__FILE__)
|
|
super
|
|
end
|
|
|
|
case F.downcase
|
|
when "git" then %W[HOMEBREW_GIT GIT]
|
|
when "svn" then %W[HOMEBREW_SVN]
|
|
else []
|
|
end.each do |key|
|
|
exec ENV[key], *ARGV if ENV[key] && File.executable?(ENV[key])
|
|
end
|
|
|
|
brew_version = File.expand_path("#{D}/../../../bin/#{F}")
|
|
exec brew_version, *ARGV if File.executable? brew_version
|
|
|
|
`/usr/bin/which -a #{F} 2>/dev/null`.split("\n").each do |path|
|
|
exec path, *ARGV
|
|
end
|
|
|
|
# xcrun hangs if xcode-select is set to "/"
|
|
path = `/usr/bin/xcode-select -print-path 2>/dev/null`.chomp
|
|
if path != "/"
|
|
path = `/usr/bin/xcrun -find #{F} 2>/dev/null`.chomp
|
|
exec path, *ARGV if File.executable? path
|
|
end
|
|
|
|
path = "/Applications/Xcode.app/Contents/Developer/usr/bin/#{F}"
|
|
exec path, *ARGV if File.executable? path
|
|
|
|
abort "You must: brew install #{F}"
|