Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Quote a name that begins with a dash or an equals sign in a command to copy
Țugui Dragoșe23d706ffb4f
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swiftindex 22439955..fcf3f5ca 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift@@ -52,10 +52,12 @@ enum Output {}/// Returns `name` so the reader can paste it into a command: in single quotes unless every character is a- /// letter, a digit, or one of `._/+-@%:=,`, which no shell reads as anything but itself.+ /// letter, a digit, or one of `._/+-@%:=,`, which no shell reads as anything but itself, and the first is+ /// neither `-`, an option to `peel`, nor `=`, a command name to zsh.static func quoted(_ name: String) -> String {let name = plain(name)let isPlain = !name.isEmpty && name.allSatisfy { $0.isLetter || $0.isNumber || "._/+-@%:=,".contains($0) }+ && !"-=".contains(name.first ?? " ")return isPlain ? name : "'\(name.replacingOccurrences(of: "'", with: "'\\''"))'"}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swiftindex dcf9b3d3..0df06d58 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift@@ -540,7 +540,9 @@ struct CommandLineTests {#expect(Output.quoted("Notes Pro") == "'Notes Pro'")#expect(Output.quoted("Editor") == "Editor")#expect(Output.quoted("Sam's Apps") == "'Sam'\\''s Apps'")- let breaking = ["Q&A", "Tools;Kit", "A|B", "(Beta)", "Cost$", "Back`tick", "Star*", "What?", "Wow!", "No#1"]+ let breaking = [+ "Q&A", "Tools;Kit", "A|B", "(Beta)", "Cost$", "Back`tick", "Star*", "What?", "Wow!", "No#1", "-Dash", "=Equal",+ ]for name in breaking + ["Sam's"] {#expect(Output.quoted(name).hasPrefix("'"), "\(name) would break the command it is pasted into")}