32
32
public func run<
33
33
Input: InputProtocol ,
34
34
Output: OutputProtocol ,
35
- Error: OutputProtocol
35
+ Error: ErrorOutputProtocol
36
36
> (
37
37
_ executable: Executable ,
38
38
arguments: Arguments = [ ] ,
@@ -74,7 +74,7 @@ public func run<
74
74
public func run<
75
75
InputElement: BitwiseCopyable ,
76
76
Output: OutputProtocol ,
77
- Error: OutputProtocol
77
+ Error: ErrorOutputProtocol
78
78
> (
79
79
_ executable: Executable ,
80
80
arguments: Arguments = [ ] ,
@@ -117,7 +117,7 @@ public func run<
117
117
/// - isolation: the isolation context to run the body closure.
118
118
/// - body: The custom execution body to manually control the running process
119
119
/// - Returns: an `ExecutableResult` type containing the return value of the closure.
120
- public func run< Result, Input: InputProtocol , Output: OutputProtocol , Error: OutputProtocol > (
120
+ public func run< Result, Input: InputProtocol , Output: OutputProtocol , Error: ErrorOutputProtocol > (
121
121
_ executable: Executable ,
122
122
arguments: Arguments = [ ] ,
123
123
environment: Environment = . inherit,
@@ -164,7 +164,7 @@ public func run<Result, Input: InputProtocol, Output: OutputProtocol, Error: Out
164
164
/// - isolation: the isolation context to run the body closure.
165
165
/// - body: The custom execution body to manually control the running process.
166
166
/// - Returns: an `ExecutableResult` type containing the return value of the closure.
167
- public func run< Result, Input: InputProtocol , Error: OutputProtocol > (
167
+ public func run< Result, Input: InputProtocol , Error: ErrorOutputProtocol > (
168
168
_ executable: Executable ,
169
169
arguments: Arguments = [ ] ,
170
170
environment: Environment = . inherit,
@@ -257,7 +257,7 @@ public func run<Result, Input: InputProtocol, Output: OutputProtocol>(
257
257
/// - isolation: the isolation context to run the body closure.
258
258
/// - body: The custom execution body to manually control the running process
259
259
/// - Returns: An `ExecutableResult` type containing the return value of the closure.
260
- public func run< Result, Error: OutputProtocol > (
260
+ public func run< Result, Error: ErrorOutputProtocol > (
261
261
_ executable: Executable ,
262
262
arguments: Arguments = [ ] ,
263
263
environment: Environment = . inherit,
@@ -391,7 +391,7 @@ public func run<Result>(
391
391
public func run<
392
392
InputElement: BitwiseCopyable ,
393
393
Output: OutputProtocol ,
394
- Error: OutputProtocol
394
+ Error: ErrorOutputProtocol
395
395
> (
396
396
_ configuration: Configuration ,
397
397
input: borrowing Span < InputElement > ,
@@ -451,7 +451,7 @@ public func run<
451
451
public func run<
452
452
Input: InputProtocol ,
453
453
Output: OutputProtocol ,
454
- Error: OutputProtocol
454
+ Error: ErrorOutputProtocol
455
455
> (
456
456
_ configuration: Configuration ,
457
457
input: Input = . none,
@@ -463,10 +463,13 @@ public func run<
463
463
standardOutput: Output . OutputType ,
464
464
standardError: Error . OutputType
465
465
)
466
+ let inputPipe = try input. createPipe ( )
467
+ let outputPipe = try output. createPipe ( )
468
+ let errorPipe = try error. createPipe ( from: outputPipe)
466
469
let result = try await configuration. run (
467
- input: try input . createPipe ( ) ,
468
- output: try output . createPipe ( ) ,
469
- error: try error . createPipe ( )
470
+ input: inputPipe ,
471
+ output: outputPipe ,
472
+ error: errorPipe
470
473
) { ( execution, inputIO, outputIO, errorIO) -> RunResult in
471
474
// Write input, capture output and error in parallel
472
475
var inputIOBox : IOChannel ? = consume inputIO
@@ -540,18 +543,21 @@ public func run<
540
543
/// - body: The custom execution body to manually control the running process
541
544
/// - Returns an executableResult type containing the return value
542
545
/// of the closure.
543
- public func run< Result, Input: InputProtocol , Output: OutputProtocol , Error: OutputProtocol > (
546
+ public func run< Result, Input: InputProtocol , Output: OutputProtocol , Error: ErrorOutputProtocol > (
544
547
_ configuration: Configuration ,
545
548
input: Input = . none,
546
549
output: Output = . discarded,
547
550
error: Error = . discarded,
548
551
isolation: isolated ( any Actor ) ? = #isolation,
549
552
body: ( ( Execution ) async throws -> Result )
550
553
) async throws -> ExecutionResult < Result > where Error. OutputType == Void {
554
+ let inputPipe = try input. createPipe ( )
555
+ let outputPipe = try output. createPipe ( )
556
+ let errorPipe = try error. createPipe ( from: outputPipe)
551
557
return try await configuration. run (
552
- input: try input . createPipe ( ) ,
553
- output: try output . createPipe ( ) ,
554
- error: try error . createPipe ( )
558
+ input: inputPipe ,
559
+ output: outputPipe ,
560
+ error: errorPipe
555
561
) { execution, inputIO, outputIO, errorIO in
556
562
var inputIOBox : IOChannel ? = consume inputIO
557
563
return try await withThrowingTaskGroup (
@@ -590,7 +596,7 @@ public func run<Result, Input: InputProtocol, Output: OutputProtocol, Error: Out
590
596
/// - body: The custom execution body to manually control the running process
591
597
/// - Returns an executableResult type containing the return value
592
598
/// of the closure.
593
- public func run< Result, Input: InputProtocol , Error: OutputProtocol > (
599
+ public func run< Result, Input: InputProtocol , Error: ErrorOutputProtocol > (
594
600
_ configuration: Configuration ,
595
601
input: Input = . none,
596
602
error: Error = . discarded,
@@ -599,10 +605,13 @@ public func run<Result, Input: InputProtocol, Error: OutputProtocol>(
599
605
body: ( ( Execution , AsyncBufferSequence ) async throws -> Result )
600
606
) async throws -> ExecutionResult < Result > where Error. OutputType == Void {
601
607
let output = SequenceOutput ( )
608
+ let inputPipe = try input. createPipe ( )
609
+ let outputPipe = try output. createPipe ( )
610
+ let errorPipe = try error. createPipe ( from: outputPipe)
602
611
return try await configuration. run (
603
- input: try input . createPipe ( ) ,
604
- output: try output . createPipe ( ) ,
605
- error: try error . createPipe ( )
612
+ input: inputPipe ,
613
+ output: outputPipe ,
614
+ error: errorPipe
606
615
) { execution, inputIO, outputIO, errorIO in
607
616
var inputIOBox : IOChannel ? = consume inputIO
608
617
var outputIOBox : IOChannel ? = consume outputIO
@@ -702,7 +711,7 @@ public func run<Result, Input: InputProtocol, Output: OutputProtocol>(
702
711
/// - body: The custom execution body to manually control the running process
703
712
/// - Returns an executableResult type containing the return value
704
713
/// of the closure.
705
- public func run< Result, Error: OutputProtocol > (
714
+ public func run< Result, Error: ErrorOutputProtocol > (
706
715
_ configuration: Configuration ,
707
716
error: Error = . discarded,
708
717
preferredBufferSize: Int ? = nil ,
@@ -711,10 +720,13 @@ public func run<Result, Error: OutputProtocol>(
711
720
) async throws -> ExecutionResult < Result > where Error. OutputType == Void {
712
721
let input = CustomWriteInput ( )
713
722
let output = SequenceOutput ( )
723
+ let inputPipe = try input. createPipe ( )
724
+ let outputPipe = try output. createPipe ( )
725
+ let errorPipe = try error. createPipe ( from: outputPipe)
714
726
return try await configuration. run (
715
- input: try input . createPipe ( ) ,
716
- output: try output . createPipe ( ) ,
717
- error: try error . createPipe ( )
727
+ input: inputPipe ,
728
+ output: outputPipe ,
729
+ error: errorPipe
718
730
) { execution, inputIO, outputIO, errorIO in
719
731
let writer = StandardInputWriter ( diskIO: inputIO!)
720
732
let outputSequence = AsyncBufferSequence (
0 commit comments