Bug #14239
closed
Added by akr (Akira Tanaka) almost 7 years ago.
Updated over 6 years ago.
Description
Recently we found open("|...") is tend to be misused.
Many people uses this method without concerning that it can run a process.
I think it should be deprecated.
So, I propose that ruby warns open("|...").
(and remove this process invoking feature in long term)
akr@fsij.org wrote:
Recently we found open("|...") is tend to be misused.
Many people uses this method without concerning that it can run a process.
I think it should be deprecated.
So, I propose that ruby warns open("|...").
Agreed. I assume this includes IO.read/binread/readlines/...?
(and remove this process invoking feature in long term)
I don't know about removal (maybe Ruby 3.x). I prefer
we be very conservative when removing (mis)features.
Agreed for warnings.
For removing, I think we have to wait for 3.0.
Matz.
matz (Yukihiro Matsumoto) wrote:
Agreed for warnings.
For removing, I think we have to wait for 3.0.
How about to add File.read etc. (similar to File.open) in 2.6?
Code like File.read(filename)
is considered to have no intention to open pipes.
normalperson (Eric Wong) wrote:
Agreed. I assume this includes IO.read/binread/readlines/...?
I intent this ticket is just for the open method.
For other methods, nobu already added warnings for
File.read("|echo a"), etc.
But the warning is not produced for IO.read("|echo a").
% ruby -e 'IO.read("|echo a")'
% ruby -e 'File.read("|echo a")'
-e:1: warning: IO.read called on File to invoke external command
I feel this is an acceptable warning behavior.
If it is not good enough, please open a new ticket.
shugo@ruby-lang.org wrote:
How about to add File.read etc. (similar to File.open) in 2.6?
Code like File.read(filename)
is considered to have no intention to open pipes.
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? :)
normalperson (Eric Wong) wrote:
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? :)
Thanks for your suggestion.
I've created a new ticket #14245.
- Status changed from Open to Closed
- Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN to 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: DONTNEED
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0Like0Like0