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, **_)
 | 
			
		||||
        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,
 | 
			
		||||
                                         print_stderr: false
 | 
			
		||||
                                 print_stderr: Homebrew::EnvConfig.developer?
 | 
			
		||||
 | 
			
		||||
        trashed = stdout.split(":").sort
 | 
			
		||||
        untrashable = stderr.split(":").sort
 | 
			
		||||
        trashed, _, untrashable = stdout.partition("\n")
 | 
			
		||||
        trashed = trashed.split(":")
 | 
			
		||||
        untrashable = untrashable.split(":")
 | 
			
		||||
 | 
			
		||||
        return trashed, untrashable if untrashable.empty?
 | 
			
		||||
 | 
			
		||||
@ -470,7 +471,7 @@ module Cask
 | 
			
		||||
          Utils.gain_permissions(path, ["-R"], SystemCommand) do
 | 
			
		||||
            system_command! HOMEBREW_LIBRARY_PATH/"cask/utils/trash.swift",
 | 
			
		||||
                            args:         [path],
 | 
			
		||||
                            print_stderr: false
 | 
			
		||||
                            print_stderr: Homebrew::EnvConfig.developer?
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
          true
 | 
			
		||||
 | 
			
		||||
@ -2,14 +2,6 @@
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
var success = true
 | 
			
		||||
@ -17,19 +9,24 @@ var success = true
 | 
			
		||||
// The command line arguments given but without the script's name
 | 
			
		||||
let CMDLineArgs = Array(CommandLine.arguments.dropFirst())
 | 
			
		||||
 | 
			
		||||
var trashed: [String] = []
 | 
			
		||||
var untrashable: [String] = []
 | 
			
		||||
for item in CMDLineArgs {
 | 
			
		||||
    do {
 | 
			
		||||
        let url = URL(fileURLWithPath: item)
 | 
			
		||||
        var trashedPath: NSURL!
 | 
			
		||||
        try manager.trashItem(at: url, resultingItemURL: &trashedPath)
 | 
			
		||||
        print((trashedPath as URL).path, terminator: ":")
 | 
			
		||||
        trashed.append((trashedPath as URL).path)
 | 
			
		||||
        success = true
 | 
			
		||||
    } catch {
 | 
			
		||||
        print(item, terminator: ":", to: &stderr)
 | 
			
		||||
        untrashable.append(item)
 | 
			
		||||
        success = false
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
print(trashed.joined(separator: ":"))
 | 
			
		||||
print(untrashable.joined(separator: ":"), terminator: "")
 | 
			
		||||
 | 
			
		||||
guard success else {
 | 
			
		||||
    exit(1)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user