File tree 2 files changed +7
-6
lines changed
2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -474,6 +474,8 @@ public final class Process {
474
474
)
475
475
var searchPaths : [ AbsolutePath ] = [ ]
476
476
#if os(Windows)
477
+ // NOTE: `CreateProcess` the Windows system API always searchs System and Windows directories first.
478
+ // See https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw#parameters
477
479
var buffer = Array < WCHAR > ( repeating: 0 , count: Int ( MAX_PATH + 1 ) )
478
480
// The 32-bit Windows system directory
479
481
if GetSystemDirectoryW ( & buffer, . init( buffer. count) ) > 0 {
Original file line number Diff line number Diff line change @@ -225,9 +225,9 @@ public func lookupExecutablePath(
225
225
return nil
226
226
}
227
227
#if os(Windows)
228
- let isPath = value. contains ( " : " ) || value. contains ( " \\ " ) || value. contains ( " / " )
228
+ let isFileName = ! value. contains ( " : " ) && ! value. contains ( " \\ " ) && ! value. contains ( " / " )
229
229
#else
230
- let isPath = value. contains ( " / " )
230
+ let isFileName = ! value. contains ( " / " )
231
231
#endif
232
232
233
233
var paths : [ AbsolutePath ] = [ ]
@@ -241,12 +241,11 @@ public func lookupExecutablePath(
241
241
paths. append ( absPath)
242
242
}
243
243
244
- // Ensure the value is not a path.
245
- if !isPath {
246
- // Try to locate in search paths.
244
+ if isFileName {
245
+ // Try to locate file in search paths.
247
246
paths. append ( contentsOf: searchPaths. map ( { $0. appending ( component: value) } ) )
248
247
#if os(Windows)
249
- if !value. contains ( " . " ) {
248
+ if !value. hasSuffix ( " . " ) {
250
249
paths. append ( contentsOf: searchPaths. map ( { $0. appending ( component: value + executableFileSuffix) } ) )
251
250
}
252
251
#endif
You can’t perform that action at this time.
0 commit comments