Ye I tried that first but it didn't work, nb_available was always zero.
For now I have a hack that works:
while true
statement, newpos = parse(code, __pos, raise=false)
statement.head == :error ? break: (__pos = newpos)
__io, _ = redirect_stdout()
print("x")
eval(statement)
redirect_stdout(STDOUT_OLD)
result = readavailable(__io)
close(__io)
if length(result) > 1
push!(__output, (__pos, result[2:end]))
end
end
On Monday, 26 May 2014 17:11:13 UTC+1, Keno Fischer wrote:
>
> nb_available(rdstd) > 0
>
>
> On Mon, May 26, 2014 at 4:51 PM, Samuel Colvin <[email protected]<javascript:>
> > wrote:
>
>> readavailable blocks if it's called on pipe with nothing to read. How
>> does one check if a pipe has something to read before calling readavailable?
>>
>> In other words,
>>
>> rdstd, wrstd = redirect_stdout()
>> eval(statement)
>> if ________
>> result = readavailable(rdstd)
>> end
>> redirect_stdout(STDOUT_OLD)
>>
>> Fill in the gap.
>>
>> I've tried a whole range of things but nothing is working, surely this
>> has a simple resolution?
>>
>
>