From: "JohanJosefsson (Johan Josefsson)" <noreply@...>
Date: 2022-07-15T18:48:09+00:00
Subject: [ruby-core:109224] [Ruby master Bug#18909] ARGF.readlines reads more than current file

Issue #18909 has been updated by JohanJosefsson (Johan Josefsson).


But this "documented API" was not implemented in the way it was described. From my limited viewpoint I would have preferred a change in the implementation and not in the documentation.
There is nothing in the introductory paragraphs on ARGF that says that the input files must be treated as a concatenated file. On the contrary, there is this 'current file' concept that is mentioned in several places.
I will maybe try to modify ARGV but that seems like a clumsy way to do what ARGF could have done if 'current file' was exposed to the user in a more suitable way.
But never mind, now I know how it works and the documentation and implementation will be in synch!
Thank you

----------------------------------------
Bug #18909: ARGF.readlines reads more than current file
https://bugs.ruby-lang.org/issues/18909#change-98361

* Author: JohanJosefsson (Johan Josefsson)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]
* Backport: 2.7: REQUIRED, 3.0: REQUIRED, 3.1: REQUIRED
----------------------------------------
The docuentation says that ARGF.readlines: *Reads ARGF's current file in its entirety* , but this is what happens:

`$ cat fileA
A
$ cat fileB
B
$ ruby -e 'puts ARGF.readlines' fileA fileB
A
B`
i.e. it reads both the current file and the next one (all files?).



-- 
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>