cask: fix trash.swift under Xcode 16
This commit is contained in:
parent
214359316f
commit
fa00d2a9fd
@ -457,12 +457,13 @@ module Cask
|
|||||||
def trash_paths(*paths, command: nil, **_)
|
def trash_paths(*paths, command: nil, **_)
|
||||||
return if paths.empty?
|
return if paths.empty?
|
||||||
|
|
||||||
stdout, stderr, = system_command HOMEBREW_LIBRARY_PATH/"cask/utils/trash.swift",
|
stdout, = system_command HOMEBREW_LIBRARY_PATH/"cask/utils/trash.swift",
|
||||||
args: paths,
|
args: paths,
|
||||||
print_stderr: false
|
print_stderr: Homebrew::EnvConfig.developer?
|
||||||
|
|
||||||
trashed = stdout.split(":").sort
|
trashed, _, untrashable = stdout.partition("\n")
|
||||||
untrashable = stderr.split(":").sort
|
trashed = trashed.split(":")
|
||||||
|
untrashable = untrashable.split(":")
|
||||||
|
|
||||||
return trashed, untrashable if untrashable.empty?
|
return trashed, untrashable if untrashable.empty?
|
||||||
|
|
||||||
@ -470,7 +471,7 @@ module Cask
|
|||||||
Utils.gain_permissions(path, ["-R"], SystemCommand) do
|
Utils.gain_permissions(path, ["-R"], SystemCommand) do
|
||||||
system_command! HOMEBREW_LIBRARY_PATH/"cask/utils/trash.swift",
|
system_command! HOMEBREW_LIBRARY_PATH/"cask/utils/trash.swift",
|
||||||
args: [path],
|
args: [path],
|
||||||
print_stderr: false
|
print_stderr: Homebrew::EnvConfig.developer?
|
||||||
end
|
end
|
||||||
|
|
||||||
true
|
true
|
||||||
|
|||||||
@ -2,14 +2,6 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
extension FileHandle : TextOutputStream {
|
|
||||||
public func write(_ string: String) {
|
|
||||||
if let data = string.data(using: .utf8) { self.write(data) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var stderr = FileHandle.standardError
|
|
||||||
|
|
||||||
let manager = FileManager.default
|
let manager = FileManager.default
|
||||||
|
|
||||||
var success = true
|
var success = true
|
||||||
@ -17,19 +9,24 @@ var success = true
|
|||||||
// The command line arguments given but without the script's name
|
// The command line arguments given but without the script's name
|
||||||
let CMDLineArgs = Array(CommandLine.arguments.dropFirst())
|
let CMDLineArgs = Array(CommandLine.arguments.dropFirst())
|
||||||
|
|
||||||
|
var trashed: [String] = []
|
||||||
|
var untrashable: [String] = []
|
||||||
for item in CMDLineArgs {
|
for item in CMDLineArgs {
|
||||||
do {
|
do {
|
||||||
let url = URL(fileURLWithPath: item)
|
let url = URL(fileURLWithPath: item)
|
||||||
var trashedPath: NSURL!
|
var trashedPath: NSURL!
|
||||||
try manager.trashItem(at: url, resultingItemURL: &trashedPath)
|
try manager.trashItem(at: url, resultingItemURL: &trashedPath)
|
||||||
print((trashedPath as URL).path, terminator: ":")
|
trashed.append((trashedPath as URL).path)
|
||||||
success = true
|
success = true
|
||||||
} catch {
|
} catch {
|
||||||
print(item, terminator: ":", to: &stderr)
|
untrashable.append(item)
|
||||||
success = false
|
success = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print(trashed.joined(separator: ":"))
|
||||||
|
print(untrashable.joined(separator: ":"), terminator: "")
|
||||||
|
|
||||||
guard success else {
|
guard success else {
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user