From 90c9561cf329540927cf411e90c430d37c803c01 Mon Sep 17 00:00:00 2001 From: iivusly Date: Thu, 28 Mar 2024 09:22:01 -0700 Subject: [PATCH] fix terminal command generation (#889) * fix the terminal command generation to run the executable instead of a directory * fix swiftlint violations Signed-off-by: iivusly --------- Signed-off-by: iivusly --- .../Sources/WhiskyKit/Extensions/Program+Extensions.swift | 4 +++- WhiskyKit/Sources/WhiskyKit/Wine/Wine.swift | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/WhiskyKit/Sources/WhiskyKit/Extensions/Program+Extensions.swift b/WhiskyKit/Sources/WhiskyKit/Extensions/Program+Extensions.swift index 055b372fd..8d589187f 100644 --- a/WhiskyKit/Sources/WhiskyKit/Extensions/Program+Extensions.swift +++ b/WhiskyKit/Sources/WhiskyKit/Extensions/Program+Extensions.swift @@ -47,7 +47,9 @@ extension Program { } public func generateTerminalCommand() -> String { - return Wine.generateRunCommand(bottle: bottle, args: settings.arguments, environment: generateEnvironment()) + return Wine.generateRunCommand( + at: self.url, bottle: bottle, args: settings.arguments, environment: generateEnvironment() + ) } public func runInTerminal() { diff --git a/WhiskyKit/Sources/WhiskyKit/Wine/Wine.swift b/WhiskyKit/Sources/WhiskyKit/Wine/Wine.swift index 1a3976f28..ecb01736f 100644 --- a/WhiskyKit/Sources/WhiskyKit/Wine/Wine.swift +++ b/WhiskyKit/Sources/WhiskyKit/Wine/Wine.swift @@ -111,8 +111,10 @@ public class Wine { ) { } } - public static func generateRunCommand(bottle: Bottle, args: String, environment: [String: String]) -> String { - var wineCmd = "\(wineBinary.esc) start /unix \(bottle.url.esc) \(args)" + public static func generateRunCommand( + at url: URL, bottle: Bottle, args: String, environment: [String: String] + ) -> String { + var wineCmd = "\(wineBinary.esc) start /unix \(url.path(percentEncoded: false)) \(args)" let env = constructWineEnvironment(for: bottle, environment: environment) for environment in env { wineCmd = "\(environment.key)=\(environment.value) " + wineCmd