From: "Eregon (Benoit Daloze)" <noreply@...>
Date: 2022-07-19T10:47:16+00:00
Subject: [ruby-core:109246] [Ruby master Bug#18909] ARGF.readlines reads more than current file

Issue #18909 has been updated by Eregon (Benoit Daloze).


JohanJosefsson (Johan Josefsson) wrote in #note-13:
> Sad to hear that. Those perl-like features have been my favorite part of ruby. It lets me be a command line ninja and make exceedingly powerful one liners while employing less magic than what I had done using perl/sed/awk/random command line utility. While all the time knowing that my tiny command line can grow, seamlessly without change of language, to a one file program, to a larger program and even to a production quality program.

To be clear, I think `ruby -e '...'` is great and useful, and I agree with your comment about growing from tiny command line to one file to larger program.
I just think `-i/-n/-p` are unnecessary because they can be replaced with just a few more characters and then you have full control and it is explicit.
It is the problem of those 3 flags, they only work in very few situations and then are useless for everything else.


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

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