From 5442a7e34f265dd625a4fe63fb5aeb8b9a9e7a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 9 Aug 2024 10:59:06 -0700 Subject: [PATCH 1/2] Honor homebrew curlrc config for analytics --- Library/Homebrew/utils/analytics.rb | 3 ++- Library/Homebrew/utils/curl.rb | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/utils/analytics.rb b/Library/Homebrew/utils/analytics.rb index 1172462d084fe..0bc02f738f9e8 100644 --- a/Library/Homebrew/utils/analytics.rb +++ b/Library/Homebrew/utils/analytics.rb @@ -54,12 +54,13 @@ def deferred_curl(url, args) require "utils/curl" curl = Utils::Curl.curl_executable + args = Utils::Curl.curl_args(*args, "--silent", "--output", "/dev/null", show_error: false) if ENV["HOMEBREW_ANALYTICS_DEBUG"] puts "#{curl} #{args.join(" ")} \"#{url}\"" puts Utils.popen_read(curl, *args, url) else pid = fork do - exec curl, *args, "--silent", "--output", "/dev/null", url + exec curl, *args, url end Process.detach T.must(pid) end diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb index a5fe7bab5fde3..fea66022a317d 100644 --- a/Library/Homebrew/utils/curl.rb +++ b/Library/Homebrew/utils/curl.rb @@ -65,7 +65,7 @@ def clear_path_cache show_error: T.nilable(T::Boolean), user_agent: T.any(String, Symbol, NilClass), referer: T.nilable(String), - ).returns(T::Array[T.untyped]) + ).returns(T::Array[String]) } def curl_args( *extra_args, @@ -129,7 +129,7 @@ def curl_args( args << "--referer" << referer if referer.present? - args + extra_args + (args + extra_args).map(&:to_s) end def curl_with_workarounds( From 2e2db25496e7625c5cda28385ca20dac6fcd28e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 9 Aug 2024 13:45:47 -0700 Subject: [PATCH 2/2] Use spawn to replace fork + exec --- Library/Homebrew/utils/analytics.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Library/Homebrew/utils/analytics.rb b/Library/Homebrew/utils/analytics.rb index 0bc02f738f9e8..c4540961a098a 100644 --- a/Library/Homebrew/utils/analytics.rb +++ b/Library/Homebrew/utils/analytics.rb @@ -59,9 +59,7 @@ def deferred_curl(url, args) puts "#{curl} #{args.join(" ")} \"#{url}\"" puts Utils.popen_read(curl, *args, url) else - pid = fork do - exec curl, *args, url - end + pid = spawn curl, *args, url Process.detach T.must(pid) end end