Merge pull request #19692 from Homebrew/services_prioritise_print

services: prioritise `launchctl print` over `launchctl list`.
This commit is contained in:
Mike McQuaid 2025-04-03 14:13:50 +00:00 committed by GitHub
commit 0c476a0a97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -235,19 +235,19 @@ module Homebrew
def status_output_success_type
@status_output_success_type ||= if System.launchctl?
cmd = [System.launchctl.to_s, "list", "#{System.domain_target}/#{service_name}"]
cmd = [System.launchctl.to_s, "print", "#{System.domain_target}/#{service_name}"]
output = Utils.popen_read(*cmd).chomp
if $CHILD_STATUS.present? && $CHILD_STATUS.success? && output.present?
success = true
odebug cmd.join(" "), output
[output, success, :launchctl_list]
type = :launchctl_print
else
cmd = [System.launchctl.to_s, "print", "#{System.domain_target}/#{service_name}"]
cmd = [System.launchctl.to_s, "list", service_name]
output = Utils.popen_read(*cmd).chomp
success = $CHILD_STATUS.present? && $CHILD_STATUS.success? && output.present?
odebug cmd.join(" "), output
[output, success, :launchctl_print]
type = :launchctl_list
end
odebug cmd.join(" "), output
[output, success, type]
elsif System.systemctl?
cmd = ["status", service_name]
output = System::Systemctl.popen_read(*cmd).chomp