@@ -39,7 +39,8 @@ public struct Configuration: Sendable {
3939 /// The environment to use when running the executable.
4040 public var environment : Environment
4141 /// 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 ?
4344 /// The platform specific options to use when
4445 /// running the subprocess.
4546 public var platformOptions : PlatformOptions
@@ -54,7 +55,7 @@ public struct Configuration: Sendable {
5455 self . executable = executable
5556 self . arguments = arguments
5657 self . environment = environment
57- self . workingDirectory = workingDirectory ?? . currentWorkingDirectory
58+ self . workingDirectory = workingDirectory
5859 self . platformOptions = platformOptions
5960 }
6061
@@ -107,7 +108,7 @@ extension Configuration: CustomStringConvertible, CustomDebugStringConvertible {
107108 executable: \( self . executable. description) ,
108109 arguments: \( self . arguments. description) ,
109110 environment: \( self . environment. description) ,
110- workingDirectory: \( self . workingDirectory) ,
111+ workingDirectory: \( self . workingDirectory? . string ?? " " ) ,
111112 platformOptions: \( self . platformOptions. description ( withIndent: 1 ) )
112113 )
113114 """
@@ -119,7 +120,7 @@ extension Configuration: CustomStringConvertible, CustomDebugStringConvertible {
119120 executable: \( self . executable. debugDescription) ,
120121 arguments: \( self . arguments. debugDescription) ,
121122 environment: \( self . environment. debugDescription) ,
122- workingDirectory: \( self . workingDirectory) ,
123+ workingDirectory: \( self . workingDirectory? . string ?? " " ) ,
123124 platformOptions: \( self . platformOptions. description ( withIndent: 1 ) )
124125 )
125126 """
@@ -714,14 +715,6 @@ internal struct CreatedPipe: ~Copyable {
714715 }
715716}
716717
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-
725718extension Optional where Wrapped: Collection {
726719 func withOptionalUnsafeBufferPointer< Result> (
727720 _ body: ( ( UnsafeBufferPointer < Wrapped . Element > ) ? ) throws -> Result
0 commit comments