Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ let result = try await run(
return lineCount
}

print(result.closureResult) // The line count returned from the closure.
print(result.standardError ?? "") // The captured standard error.
print(result.closureResult) // The line count returned from the closure.
print(result.standardError) // The captured standard error.
```

Stream both standard output and standard error, writing to standard input from the same closure:
Expand Down
4 changes: 2 additions & 2 deletions Sources/Subprocess/IO/Output.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ public struct FileDescriptorOutput: OutputProtocol, ErrorOutputProtocol {

/// An output type that collects the subprocess's output as decoded text using the given encoding.
public struct StringOutput<Encoding: Unicode.Encoding>: OutputProtocol, ErrorOutputProtocol {
public typealias OutputType = String?
public typealias OutputType = String
public let maxSize: Int

public func output(from span: RawSpan) throws -> String? {
public func output(from span: RawSpan) throws -> String {
span.withUnsafeBytes { ptr in
let array = Array(ptr)
return String(decodingBytes: array, as: Encoding.self)
Expand Down
5 changes: 2 additions & 3 deletions Tests/SubprocessTests/DarwinTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ struct SubprocessDarwinTests {
output: .string(limit: .max)
)
#expect(pwdResult.terminationStatus.isSuccess)
let currentDir = try #require(
pwdResult.standardOutput
).trimmingCharacters(in: .whitespacesAndNewlines)
let currentDir = pwdResult.standardOutput
.trimmingCharacters(in: .whitespacesAndNewlines)
// On Darwin, /var is linked to /private/var; /tmp is linked /private/tmp
var expected = FilePath(intendedWorkingDir)
if expected.starts(with: "/var") || expected.starts(with: "/tmp") {
Expand Down
Loading
Loading