cask/artifiact/abstract_uninstall: allow wildcard entries for launchctl
This commit is contained in:
parent
33d3a5d728
commit
836efe621f
@ -95,14 +95,10 @@ module Cask
|
|||||||
|
|
||||||
# if launchctl item contains a wildcard, find matching process(es)
|
# if launchctl item contains a wildcard, find matching process(es)
|
||||||
services.each do |service|
|
services.each do |service|
|
||||||
all_services.push(service)
|
all_services << service
|
||||||
next unless /\*/.match?(service)
|
next unless service.include?("*")
|
||||||
|
|
||||||
find_launchctl_with_wildcard(service)
|
all_services += find_launchctl_with_wildcard(service)
|
||||||
.map { |_, _, id| id }
|
|
||||||
.each do |match|
|
|
||||||
all_services.push(match)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
all_services.each do |service|
|
all_services.each do |service|
|
||||||
@ -284,13 +280,13 @@ module Cask
|
|||||||
end
|
end
|
||||||
|
|
||||||
def find_launchctl_with_wildcard(search)
|
def find_launchctl_with_wildcard(search)
|
||||||
|
regex = Regexp.escape(search).gsub("\\*", ".*")
|
||||||
system_command!("/bin/launchctl", args: ["list"])
|
system_command!("/bin/launchctl", args: ["list"])
|
||||||
.stdout.lines.drop(1)
|
.stdout.lines.drop(1)
|
||||||
.map { |line| line.chomp.split("\t") }
|
.map do |line|
|
||||||
.map { |pid, state, id| [pid.to_i, state.to_i, id] }
|
pid, _state, id = line.chomp.split("\t")
|
||||||
.select do |(pid, _, id)|
|
id if pid.to_i.nonzero? && id.match?(regex)
|
||||||
pid.nonzero? && /\A#{Regexp.escape(search).gsub("\\*", ".*")}\Z/.match?(id)
|
end.compact
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# :kext should be unloaded before attempting to delete the relevant file
|
# :kext should be unloaded before attempting to delete the relevant file
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user