diff --git a/Sources/TSCBasic/misc.swift b/Sources/TSCBasic/misc.swift index 62d2376e..f8ae38d3 100644 --- a/Sources/TSCBasic/misc.swift +++ b/Sources/TSCBasic/misc.swift @@ -94,18 +94,12 @@ public func lookupExecutablePath( ) -> AbsolutePath? { // We should have a value to continue. -#if os(Windows) - guard var value = value, !value.isEmpty else { - return nil - } - let isPath = value.contains("\\") || value.contains("/") - if !isPath && !value.contains(".") { - value.append(executableFileSuffix) - } -#else guard let value = value, !value.isEmpty else { return nil } +#if os(Windows) + let isPath = value.contains(":") || value.contains("\\") || value.contains("/") +#else let isPath = value.contains("/") #endif @@ -124,6 +118,11 @@ public func lookupExecutablePath( if !isPath { // Try to locate in search paths. paths.append(contentsOf: searchPaths.map({ $0.appending(component: value) })) +#if os(Windows) + if !value.contains(".") { + paths.append(contentsOf: searchPaths.map({ $0.appending(component: value + executableFileSuffix) })) + } +#endif } return paths.first(where: { localFileSystem.isExecutableFile($0) })