Project

General

Profile

Actions

Feature #14245

closed

Add File.read etc.

Added by shugo (Shugo Maeda) over 6 years ago. Updated about 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:84495]

Description

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? :)


Files

0001-io.c.patch (2.39 KB) 0001-io.c.patch shugo (Shugo Maeda), 03/17/2018 11:47 AM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #14239: warn open("|...")ClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0