diff --git a/SwiftShell/Pipes.swift b/SwiftShell/Pipes.swift index 9e8a4ec..dbe84b9 100644 --- a/SwiftShell/Pipes.swift +++ b/SwiftShell/Pipes.swift @@ -26,20 +26,25 @@ public func |> (lhs: T, rhs:((T,V) -> U, V)) -> U { } */ -/* crashes the compiler (beta 6) +/* crashes the compiler (beta 6). +Should replace the function below as it is more general and will also work with strings. + public func |> (lhs: Streamable, inout rhs: OutputStreamType) { + + // specifically its these that crash the compiler, not the function definition. // lhs.writeTo(&rhs) - // rhs.write(lhs.read()) + // rhs.write(lhs.) // print(lhs, &rhs) } */ + /** Prints one stream to another. readablestream |> writablestream */ -public func |> (lhs: ReadableStreamType, inout rhs: WriteableStreamType) { +public func |> (lhs: ReadableStreamType, rhs: WriteableStreamType) { rhs.write(lhs.read()) } diff --git a/SwiftShellTests/Scripts/Stream out.swift b/SwiftShellTests/Scripts/Stream out.swift new file mode 100644 index 0000000..5097ec1 --- /dev/null +++ b/SwiftShellTests/Scripts/Stream out.swift @@ -0,0 +1,4 @@ + +import SwiftShell + +run("ls") |> standardoutput