Add File.read etc.
Some people use File.open without knowing that it's defined in IO and pipes can be opened.
p File.read("|echo hello") #-> "hello"
How about to add File.read, File.binread, File.foreach etc. (similar version to File.open)?
Code like File.read(filename) is considered to have no intention to open pipes.
Implementation by prelude.rb is suggested by normalperson in #14239:
I like that idea, I've been rewriting some stuff to use
"File.open(filename, &:read)" instead of IO.read.
Now, can we implement these new singleton methods in
prelude.rb instead of writing in C? :)
#3 [ruby-core:84499] Updated by akr (Akira Tanaka) 26 days ago
If I understand this proposal correctly,
this proposal means that adding File.read method and
doesn't change IO.read method?
I.e. IO.read("|command") is works as now?.
I think it is possible direction.
Apart from that, we should list all affected methods explicitly (without "etc.").
#4 [ruby-core:84504] Updated by shevegen (Robert A. Heiler) 26 days ago
Code like File.read(filename) is considered to
have no intention to open pipes.
When added, the documentation should also
briefly mention the reference to pipes.
For example, a few months ago I did not even know
about the leading '|' character - I first saw it
on the ruby issue tracker. :)
Current link to File is here: