Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Say what Homebrew's target and a closed pipe really do

Țugui Dragoșf0661bb03e01
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
index 383fe80a..be9030c0 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
@@ -60,8 +60,9 @@ enum Output {
}
/// Writes `text` to standard output unchanged, for output that already ends in a newline. When the write fails
- /// (a closed stdout, a full disk), the tool exits with status 1. `FileHandle.write(_:)` would instead raise an
- /// exception Swift can't catch, and the tool would crash.
+ /// (a full disk, a closed stdout), the tool exits with status 1. `FileHandle.write(_:)` would instead raise an
+ /// exception Swift can't catch, and the tool would crash. A pipe whose reader has gone ends the process with
+ /// SIGPIPE before the write returns (`man 2 write`), except while a removal ignores the signal (`Uninterrupted`).
static func write(_ text: String) {
if let collected {
collected.add(output: text)
diff --git a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
index bec9f6f1..529ea100 100644
--- a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
@@ -285,7 +285,8 @@ struct CaskArtifact: Decodable, Sendable {
appNames = ((app?.strings ?? []) + (app?.dictionaries ?? []).flatMap { $0["target"]?.strings ?? [] })
.map { ($0 as NSString).lastPathComponent }
.filter { !$0.isEmpty }
- // An installed cask also says where the app went: `{"app": [...], "target": "/Applications/Krita.app"}`.
+ // Homebrew writes where each artifact it moves goes, installed or not:
+ // `{"app": [...], "target": "/Applications/Krita.app"}`.
appTargets = app == nil ? [] : (raw["target"]?.strings ?? []).filter { $0.hasPrefix("/") }
// A command's link is written the same way: `{"binary": [...], "target": "/opt/homebrew/bin/studio"}`.
commandLinks = raw["binary"] == nil ? [] : (raw["target"]?.strings ?? []).filter { $0.hasPrefix("/") }