@@ -39,7 +39,8 @@ public struct Configuration: Sendable {
39
39
/// The environment to use when running the executable.
40
40
public var environment : Environment
41
41
/// The working directory to use when running the executable.
42
- public var workingDirectory : FilePath
42
+ /// If this property is `nil`, the subprocess will inherit the working directory from the parent process.
43
+ public var workingDirectory : FilePath ?
43
44
/// The platform specific options to use when
44
45
/// running the subprocess.
45
46
public var platformOptions : PlatformOptions
@@ -54,7 +55,7 @@ public struct Configuration: Sendable {
54
55
self . executable = executable
55
56
self . arguments = arguments
56
57
self . environment = environment
57
- self . workingDirectory = workingDirectory ?? . currentWorkingDirectory
58
+ self . workingDirectory = workingDirectory
58
59
self . platformOptions = platformOptions
59
60
}
60
61
@@ -107,7 +108,7 @@ extension Configuration: CustomStringConvertible, CustomDebugStringConvertible {
107
108
executable: \( self . executable. description) ,
108
109
arguments: \( self . arguments. description) ,
109
110
environment: \( self . environment. description) ,
110
- workingDirectory: \( self . workingDirectory) ,
111
+ workingDirectory: \( self . workingDirectory? . string ?? " " ) ,
111
112
platformOptions: \( self . platformOptions. description ( withIndent: 1 ) )
112
113
)
113
114
"""
@@ -119,7 +120,7 @@ extension Configuration: CustomStringConvertible, CustomDebugStringConvertible {
119
120
executable: \( self . executable. debugDescription) ,
120
121
arguments: \( self . arguments. debugDescription) ,
121
122
environment: \( self . environment. debugDescription) ,
122
- workingDirectory: \( self . workingDirectory) ,
123
+ workingDirectory: \( self . workingDirectory? . string ?? " " ) ,
123
124
platformOptions: \( self . platformOptions. description ( withIndent: 1 ) )
124
125
)
125
126
"""
@@ -714,14 +715,6 @@ internal struct CreatedPipe: ~Copyable {
714
715
}
715
716
}
716
717
717
- extension FilePath {
718
- static var currentWorkingDirectory : Self {
719
- let path = getcwd ( nil , 0 ) !
720
- defer { free ( path) }
721
- return . init( String ( cString: path) )
722
- }
723
- }
724
-
725
718
extension Optional where Wrapped: Collection {
726
719
func withOptionalUnsafeBufferPointer< Result> (
727
720
_ body: ( ( UnsafeBufferPointer < Wrapped . Element > ) ? ) throws -> Result
0 commit comments