aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2014-12-16 15:27:36 -0500
committerJack Nagel2014-12-16 15:51:57 -0500
commita73ec7bd90624dc83f1f6b3bcee8eddb83d6a7b9 (patch)
tree954cc277c28d986f39adb032db0a9b87067166c5 /Library
parent4b808be658a81e8312b95375fb75ebe3046da74e (diff)
downloadhomebrew-a73ec7bd90624dc83f1f6b3bcee8eddb83d6a7b9.tar.bz2
Use Utils.popen_read to avoid shelling out in a few places
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/download_strategy.rb10
-rw-r--r--Library/Homebrew/os/mac.rb6
-rw-r--r--Library/Homebrew/os/mac/xcode.rb2
3 files changed, 6 insertions, 12 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index bc31babd9..65d47c161 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -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
diff --git a/Library/Homebrew/os/mac.rb b/Library/Homebrew/os/mac.rb
index e1f838862..29fcbe958 100644
--- a/Library/Homebrew/os/mac.rb
+++ b/Library/Homebrew/os/mac.rb
@@ -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
diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb
index c4e53504f..5d5e02d9a 100644
--- a/Library/Homebrew/os/mac/xcode.rb
+++ b/Library/Homebrew/os/mac/xcode.rb
@@ -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