
Using `git` from `Formula#install` can cause an exec bomb if used in a formula with `env :userpaths` because that causes both `Library/ENV/4.3` and `Library/ENV/scm` to be in PATH, both of which contain a `git` binary that is the same SCM wrapper. Those will mutually exec each other indefinitely as they fail to detect that they are the same wrapper. Extend the exec-bomb protection to check the paths after all symbolic links have been expanded to prevent this situation. Fixes #43. Fixes Homebrew/homebrew-core#133. Fixed Homebrew/homebrew-core#143. Closes #46. Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
64 lines
1.8 KiB
Bash
Executable File
64 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
# Make sure this shim uses the same Ruby interpreter that is used by Homebrew.
|
|
unset RUBYLIB
|
|
unset RUBYOPT
|
|
if [ -z "$HOMEBREW_RUBY_PATH" ]
|
|
then
|
|
echo "${0##*/}: The build tool has reset ENV; --env=std required." >&2
|
|
exit 1
|
|
fi
|
|
exec "$HOMEBREW_RUBY_PATH" -x "$0" "$@"
|
|
#!/usr/bin/env ruby -W0
|
|
|
|
# This script because we support $GIT, $HOMEBREW_SVN, etc., Xcode-only and
|
|
# no Xcode/CLT configurations. Order is careful to be what the user would want.
|
|
|
|
require "pathname"
|
|
|
|
SELF_REAL = Pathname.new(__FILE__).realpath
|
|
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 || Pathname.new(arg0).realpath == SELF_REAL
|
|
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 unless path == "/usr/bin/#{F}"
|
|
end
|
|
|
|
popup_stub = false
|
|
if File.executable? "/usr/bin/xcode-select"
|
|
# xcode-select will return empty on no Xcode/CLT configuration.
|
|
# /usr/bin/<tool> will be a popup stub under such configuration.
|
|
# xcrun hangs if xcode-select is set to "/"
|
|
path = `/usr/bin/xcode-select -print-path 2>/dev/null`.chomp
|
|
popup_stub = path.empty?
|
|
if !popup_stub && path != "/"
|
|
path = `/usr/bin/xcrun -find #{F} 2>/dev/null`.chomp
|
|
exec path, *ARGV if File.executable? path
|
|
end
|
|
end
|
|
|
|
path = "/Applications/Xcode.app/Contents/Developer/usr/bin/#{F}"
|
|
exec path, *ARGV if File.executable? path
|
|
|
|
path = "/usr/bin/#{F}"
|
|
exec path, *ARGV if !popup_stub && File.executable?(path)
|
|
|
|
abort "You must: brew install #{F}"
|