Readlines() in v 0.5 and 0.6


#1

If I use readlines(\ls`)` in v 0.5 (precompiled binary) there is no problem, however in v 0.6 (Version 0.6.0-dev.2375) I get

> readlines(`ls`)
ERROR: MethodError: no method matching readlines(::Cmd)
Closest candidates are:
  readlines() at io.jl:214
  readlines(::AbstractString; chomp) at io.jl:210
  readlines(::IO; chomp) at io.jl:214

Now interestingly a help request in v 0.5 shows that there is no “method matching readlines(::Cmd)” either, but still it runs. I wonder if there has been a change in what is understood by an IOStream in the two versions of Julia, or the description of what the ::Cmd symbol does?

I tried adding a boolean for chomp but it did not like that either.
What does the candidate readlines() with no expected argument do? It appears to be waiting for STDIN?


#2

This was changed in https://github.com/JuliaLang/julia/pull/20203 … I think it may have been an unintentional change (the first argument to readlines was too strictly typed), and a PR to change it back would be welcome. (Also, better documentation.)

For now, you can still do

collect(eachline(`ls`))

Yes, readlines() with no arguments reads from STDIN.


#3

Thank you for this feedback. FWIW I now have everything working again in both 0.5 and 0.6 using
split(chomp(readstring(...)))
so the engine is back on the rails.