blob: 7539ecfc01894c5b271a50ac96995bf04c973c2c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/usr/bin/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 = if args.size == 1
args.first.split(' ')
else
args
end.first
return if arg0 =~ /^#{F}/i
return if File.expand_path(arg0) == File.expand_path(__FILE__)
if args[1] == '-print-path' and File.executable? args[0]
puts args[0]
exit 0
else
Kernel.exec *args
end
end
case F.downcase
when 'git' then %W{HOMEBREW_GIT GIT}
when 'svn' then "HOMEBREW_SVN"
else []
end.each do |key|
exec ENV[key], *ARGV if ENV[key] and 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}"
|