2019-05-09 18:39:21 +00:00
|
|
|
#!/usr/bin/swift
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
2019-10-01 11:12:23 +00:00
|
|
|
struct swifterr: TextOutputStream {
|
|
|
|
public static var stream = swifterr()
|
|
|
|
mutating func write(_ string: String) { fputs(string, stderr) }
|
|
|
|
}
|
|
|
|
|
2019-05-09 18:39:21 +00:00
|
|
|
if (CommandLine.arguments.count < 2) {
|
|
|
|
exit(2)
|
|
|
|
}
|
|
|
|
|
|
|
|
let manager: FileManager = FileManager()
|
|
|
|
|
|
|
|
for item in CommandLine.arguments[1...] {
|
|
|
|
do {
|
|
|
|
let path: URL = URL(fileURLWithPath: item)
|
|
|
|
try manager.trashItem(at: path, resultingItemURL: nil)
|
2019-10-01 11:12:23 +00:00
|
|
|
print(path, terminator: "\0")
|
2019-05-09 18:39:21 +00:00
|
|
|
}
|
|
|
|
catch {
|
2019-10-01 11:12:23 +00:00
|
|
|
print(error.localizedDescription, to: &swifterr.stream)
|
|
|
|
exit(1)
|
2019-05-09 18:39:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exit(0)
|