@@ -15,7 +15,9 @@ import Foundation
1515 * - parameter arguments: The arguments to pass to the command
1616 * - parameter path: The path to execute the commands at (defaults to current folder)
1717 * - parameter outputHandle: Any `FileHandle` that any output (STDOUT) should be redirected to
18+ * (at the moment this is only supported on macOS)
1819 * - parameter errorHandle: Any `FileHandle` that any error output (STDERR) should be redirected to
20+ * (at the moment this is only supported on macOS)
1921 *
2022 * - returns: The output of running the command
2123 * - throws: `ShellOutError` in case the command couldn't be performed, or it returned an error
@@ -39,7 +41,9 @@ import Foundation
3941 * - parameter commands: The commands to run
4042 * - parameter path: The path to execute the commands at (defaults to current folder)
4143 * - parameter outputHandle: Any `FileHandle` that any output (STDOUT) should be redirected to
44+ * (at the moment this is only supported on macOS)
4245 * - parameter errorHandle: Any `FileHandle` that any error output (STDERR) should be redirected to
46+ * (at the moment this is only supported on macOS)
4347 *
4448 * - returns: The output of running the command
4549 * - throws: `ShellOutError` in case the command couldn't be performed, or it returned an error
@@ -315,34 +319,42 @@ private extension Process {
315319 var outputData = Data ( )
316320 var errorData = Data ( )
317321
318- let stdoutHandler : ( FileHandle ) -> Void = { handler in
322+ let outputPipe = Pipe ( )
323+ standardOutput = outputPipe
324+
325+ let errorPipe = Pipe ( )
326+ standardError = errorPipe
327+
328+ #if !os(Linux)
329+ outputPipe. fileHandleForReading. readabilityHandler = { handler in
319330 let data = handler. availableData
320331 outputData. append ( data)
321332 outputHandle? . write ( data)
322333 }
323334
324- let stderrHandler : ( FileHandle ) -> Void = { handler in
335+ errorPipe . fileHandleForReading . readabilityHandler = { handler in
325336 let data = handler. availableData
326337 errorData. append ( data)
327338 errorHandle? . write ( data)
328339 }
340+ #endif
329341
330- let outputPipe = Pipe ( )
331- standardOutput = outputPipe
332- outputPipe. fileHandleForReading. readabilityHandler = stdoutHandler
342+ launch ( )
333343
334- let errorPipe = Pipe ( )
335- standardError = errorPipe
336- errorPipe. fileHandleForReading. readabilityHandler = stderrHandler
344+ #if os(Linux)
345+ outputData = outputPipe. fileHandleForReading. readDataToEndOfFile ( )
346+ errorData = errorPipe. fileHandleForReading. readDataToEndOfFile ( )
347+ #endif
337348
338- launch ( )
339349 waitUntilExit ( )
340350
341351 outputHandle? . closeFile ( )
342352 errorHandle? . closeFile ( )
343353
354+ #if !os(Linux)
344355 outputPipe. fileHandleForReading. readabilityHandler = nil
345356 errorPipe. fileHandleForReading. readabilityHandler = nil
357+ #endif
346358
347359 if terminationStatus != 0 {
348360 throw ShellOutError (
0 commit comments