aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils
diff options
context:
space:
mode:
authorDavid Broder-Rodgers2017-01-30 18:31:52 +0000
committerDavid Broder-Rodgers2017-01-30 18:31:52 +0000
commit13a3a57fa86678e3a3cb9272fe04285cb538c55b (patch)
treec345802d70ff32e2f787986b2f5392ac76f367fb /Library/Homebrew/utils
parent3c566399cf8dab3aff8c54381e7b83b0e6ef3995 (diff)
parent35045b2934d94eabe302693a05b12fb530827454 (diff)
downloadbrew-13a3a57fa86678e3a3cb9272fe04285cb538c55b.tar.bz2
Merge remote-tracking branch 'origin/master' into insecure_audit
Diffstat (limited to 'Library/Homebrew/utils')
-rw-r--r--Library/Homebrew/utils/analytics.rb2
-rw-r--r--Library/Homebrew/utils/analytics.sh2
-rw-r--r--Library/Homebrew/utils/curl.rb32
-rw-r--r--Library/Homebrew/utils/inreplace.rb3
4 files changed, 27 insertions, 12 deletions
diff --git a/Library/Homebrew/utils/analytics.rb b/Library/Homebrew/utils/analytics.rb
index cc7ad54d2..7dd54d3f1 100644
--- a/Library/Homebrew/utils/analytics.rb
+++ b/Library/Homebrew/utils/analytics.rb
@@ -35,7 +35,7 @@ module Utils
end
# Send analytics. Don't send or store any personally identifiable information.
- # https://github.com/Homebrew/brew/blob/master/docs/Analytics.md
+ # http://docs.brew.sh/Analytics.html
# https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide
# https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
if ENV["HOMEBREW_ANALYTICS_DEBUG"]
diff --git a/Library/Homebrew/utils/analytics.sh b/Library/Homebrew/utils/analytics.sh
index 0f188fe9b..35f91eabc 100644
--- a/Library/Homebrew/utils/analytics.sh
+++ b/Library/Homebrew/utils/analytics.sh
@@ -107,7 +107,7 @@ report-analytics-screenview-command() {
)
# Send analytics. Don't send or store any personally identifiable information.
- # https://github.com/Homebrew/brew/blob/master/docs/Analytics.md
+ # http://docs.brew.sh/Analytics.html
# https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide#screenView
# https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
if [[ -z "$HOMEBREW_ANALYTICS_DEBUG" ]]
diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb
index 00c3a591c..5a40ae846 100644
--- a/Library/Homebrew/utils/curl.rb
+++ b/Library/Homebrew/utils/curl.rb
@@ -1,27 +1,41 @@
require "pathname"
require "open3"
-def curl_args(extra_args = [])
+def curl_args(options = {})
curl = Pathname.new ENV["HOMEBREW_CURL"]
curl = Pathname.new "/usr/bin/curl" unless curl.exist?
raise "#{curl} is not executable" unless curl.exist? && curl.executable?
- flags = HOMEBREW_CURL_ARGS
- flags -= ["--progress-bar"] if ARGV.verbose?
+ args = [
+ curl.to_s,
+ "--remote-time",
+ "--location",
+ ]
- args = [curl.to_s] + flags + extra_args
- args << "--verbose" if ENV["HOMEBREW_CURL_VERBOSE"]
- args << "--silent" if !$stdout.tty? || ENV["TRAVIS"]
+ case options[:user_agent]
+ when :browser
+ args << "--user-agent" << HOMEBREW_USER_AGENT_FAKE_SAFARI
+ else
+ args << "--user-agent" << HOMEBREW_USER_AGENT_CURL
+ end
+
+ unless options[:show_output]
+ args << "--progress-bar" unless ARGV.verbose?
+ args << "--verbose" if ENV["HOMEBREW_CURL_VERBOSE"]
+ args << "--fail"
+ args << "--silent" if !$stdout.tty? || ENV["TRAVIS"]
+ end
+
+ args += options[:extra_args] if options[:extra_args]
args
end
def curl(*args)
- safe_system(*curl_args(args))
+ safe_system(*curl_args(extra_args: args))
end
def curl_output(*args)
- curl_args = curl_args(args)
- curl_args -= ["--fail", "--silent"]
+ curl_args = curl_args(extra_args: args, show_output: true)
Open3.popen3(*curl_args) do |_, stdout, stderr, wait_thread|
[stdout.read, stderr.read, wait_thread.value]
end
diff --git a/Library/Homebrew/utils/inreplace.rb b/Library/Homebrew/utils/inreplace.rb
index c7557ab41..b4c219f06 100644
--- a/Library/Homebrew/utils/inreplace.rb
+++ b/Library/Homebrew/utils/inreplace.rb
@@ -1,9 +1,10 @@
module Utils
class InreplaceError < RuntimeError
def initialize(errors)
- super errors.inject("inreplace failed\n") do |s, (path, errs)|
+ formatted_errors = errors.inject("inreplace failed\n") do |s, (path, errs)|
s << "#{path}:\n" << errs.map { |e| " #{e}\n" }.join
end
+ super formatted_errors
end
end