How to convert an IOBuffer to an IOStream?


#1

Hi there,
I would like to feed a string as standard input to a command; a silly example is that I want to print “b” as follows:

julia> input = IOBuffer("a")
julia> open(`tr a b`, "r", input) do output
    print(readline(output))
end

however I get weird error messages: in 0.6,
ERROR: MethodError: no method matching uvtype(::Base.AbstractIOBuffer{Array{UInt8,1}})
and in 0.7.0-DEV.5260,
ERROR: MethodError: no method matching rawhandle(::Base.GenericIOBuffer{Array{UInt8,1}})

so it seems that although I can read from an IOBuffer I can’t pass it as stdio to open.

There must be a way to encapsulate the IOBuffer into an IOStream, but I haven’t found it.