[#104481] [Ruby master Feature#18020] Introduce `IO::Buffer` for fiber scheduler. — samuel@...

Issue #18020 has been reported by ioquatix (Samuel Williams).

31 messages 2021/07/03

[#104492] [Ruby master Bug#18022] Spec errors for rbconfig/unicode_[emoji_]version_spec: Using Ruby 2.7 even when on Ruby 3.1 — duerst@...

Issue #18022 has been reported by duerst (Martin D=FCrst).

8 messages 2021/07/04

[#104552] [Ruby master Feature#18033] Time.new to parse a string — nobu@...

Issue #18033 has been reported by nobu (Nobuyoshi Nakada).

26 messages 2021/07/09

[#104560] [Ruby master Bug#18035] Introduce general module for immutable by default. — samuel@...

Issue #18035 has been reported by ioquatix (Samuel Williams).

41 messages 2021/07/09

[#104629] [Ruby master Misc#18039] DevelopersMeeting20210819Japan — mame@...

Issue #18039 has been reported by mame (Yusuke Endoh).

11 messages 2021/07/16

[#104643] [Ruby master Bug#18040] Why should `foo(1 if true)` be an error? — bughit.github@...

Issue #18040 has been reported by bughit (bug hit).

10 messages 2021/07/19

[#104665] [Ruby master Feature#18042] YARV code optimization — motoroller95@...

Issue #18042 has been reported by motoroller (Iskandar Gohar).

11 messages 2021/07/23

[#104692] [Ruby master Bug#18048] Thread#join can break with fiber scheduler unblock fails or blocks. — samuel@...

Issue #18048 has been reported by ioquatix (Samuel Williams).

10 messages 2021/07/27

[#104723] [Ruby master Bug#18054] No rule to make target 'thread_fd_close.c', needed by 'thread_fd_close.o' — duerst@...

Issue #18054 has been reported by duerst (Martin D=FCrst).

8 messages 2021/07/29

[ruby-core:104627] [Ruby master Feature#17994] Clarify `IO.read` behavior and add `File.read` method

From: mame@...
Date: 2021-07-16 03:04:56 UTC
List: ruby-core #104627
Issue #17994 has been updated by mame (Yusuke Endoh).


I noticed that this issue is not only in `IO.read` but also in `IO.binread`, `IO.write`, `IO.binwrite`, and `IO.readlines`.
Adding `File.binread` etc. is clearly hard to maintain, so I agree that we should change only the doc of `IO.read` etc.

I have no strong opinion about prohibiting Socket.read etc. `IO.read` is a tricky class method because it changes its behavior depending on its receiver class, so it makes sense if the receiver is neither IO or File, but I'd like to keep the behavior if anyone is against the change.

----------------------------------------
Feature #17994: Clarify `IO.read` behavior and add `File.read` method
https://bugs.ruby-lang.org/issues/17994#change-92922

* Author: mame (Yusuke Endoh)
* Status: Open
* Priority: Normal
----------------------------------------
`IO.read` creates a subprocess when a given file name starts with a `|` character.

```
irb(main):001:0> IO.read("| ls /etc/passwd")
=> "/etc/passwd\n"
```

To disable this feature, `File.read` can be used.

```
irb(main):002:0> File.read("| ls /etc/passwd")
(irb):2:in `read': No such file or directory @ rb_sysopen - | ls /etc/passwd (Errno::ENOENT)
```

So, as far as I know, `File.read` is more prefereable to `IO.read` if a user want to just read a file.

However, in terms of the implementation, there is no definition of `File.read`. `File.read` invokes `IO.read` because `IO` is a superclass of `File`, and `IO.read` creates a subprocess only when its receiver is exactly the `IO` class.

I think there are two problems in the current situation:

1. The rdoc of `IO.read` does not explain the behavior to disable a subprocess invocation.
2. The rdoc does not have an entry for `File.read`.

I've created a PR to address the two issues by clarifying `IO.read` behavior and defining `File.read` as an alias to `IO.read`.

https://github.com/ruby/ruby/pull/4579



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next