diff --git a/BrewBar/BrewBarApp.swift b/BrewBar/BrewBarApp.swift index 0499a28..22c96b7 100644 --- a/BrewBar/BrewBarApp.swift +++ b/BrewBar/BrewBarApp.swift @@ -169,10 +169,15 @@ class AppDelegate: NSObject, NSApplicationDelegate { return url } + /// Serial: brew commands run strictly one after another. Concurrent brew + /// processes could each summon their own sudo password dialog (and their + /// log output interleaved); queueing them prevents both. + static let brewQueue = DispatchQueue(label: "fr.socheleau.BrewBar.brew") + /// askpassMessage customizes the sudo dialog ("...password to ."); /// defaults to naming the brew command. func runBrew(_ command: String, askpassMessage: String? = nil, completion: @escaping (String) -> Void = { _ in }) { - DispatchQueue.global().async { + Self.brewQueue.async { let brew = self.resolveBrewPath() let cleaned = command.replacingOccurrences(of: "brew ", with: "") let arguments = [brew] + cleaned.split(separator: " ").map(String.init)