Use Utils.popen_read to avoid shelling out in a few places
This commit is contained in:
parent
8c0928ccca
commit
9a2f2aee7e
@ -436,17 +436,11 @@ class SubversionDownloadStrategy < VCSDownloadStrategy
|
||||
private
|
||||
|
||||
def repo_url
|
||||
`svn info '#{cached_location}' 2>/dev/null`.strip[/^URL: (.+)$/, 1]
|
||||
end
|
||||
|
||||
def shell_quote str
|
||||
# Oh god escaping shell args.
|
||||
# See http://notetoself.vrensk.com/2008/08/escaping-single-quotes-in-ruby-harder-than-expected/
|
||||
str.gsub(/\\|'/) { |c| "\\#{c}" }
|
||||
Utils.popen_read("svn", "info", cached_location.to_s).strip[/^URL: (.+)$/, 1]
|
||||
end
|
||||
|
||||
def get_externals
|
||||
`svn propget svn:externals '#{shell_quote(@url)}'`.chomp.each_line do |line|
|
||||
Utils.popen_read("svn", "propget", "svn:externals", @url).chomp.each_line do |line|
|
||||
name, url = line.split(/\s+/)
|
||||
yield name, url
|
||||
end
|
||||
|
||||
@ -30,21 +30,21 @@ module OS
|
||||
elsif File.executable?(path = "#{HOMEBREW_PREFIX}/bin/#{tool}")
|
||||
Pathname.new path
|
||||
else
|
||||
path = `/usr/bin/xcrun -no-cache -find #{tool} 2>/dev/null`.chomp
|
||||
path = Utils.popen_read("/usr/bin/xcrun", "-no-cache", "-find", tool).chomp
|
||||
Pathname.new(path) if File.executable?(path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def active_developer_dir
|
||||
@active_developer_dir ||= `xcode-select -print-path 2>/dev/null`.strip
|
||||
@active_developer_dir ||= Utils.popen_read("/usr/bin/xcode-select", "-print-path").strip
|
||||
end
|
||||
|
||||
def sdk_path(v = version)
|
||||
(@sdk_path ||= {}).fetch(v.to_s) do |key|
|
||||
opts = []
|
||||
# First query Xcode itself
|
||||
opts << `#{locate('xcodebuild')} -version -sdk macosx#{v} Path 2>/dev/null`.chomp
|
||||
opts << Utils.popen_read(locate("xcodebuild"), "-version", "-sdk", "macosx#{v}", "Path").chomp
|
||||
# Xcode.prefix is pretty smart, so lets look inside to find the sdk
|
||||
opts << "#{Xcode.prefix}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX#{v}.sdk"
|
||||
# Xcode < 4.3 style
|
||||
|
||||
@ -77,7 +77,7 @@ module OS
|
||||
|
||||
%W[#{prefix}/usr/bin/xcodebuild #{which("xcodebuild")}].uniq.each do |path|
|
||||
if File.file? path
|
||||
`#{path} -version 2>/dev/null` =~ /Xcode (\d(\.\d)*)/
|
||||
Utils.popen_read(path, "-version") =~ /Xcode (\d(\.\d)*)/
|
||||
return $1 if $1
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user