From: "JohanJosefsson (Johan Josefsson)" Date: 2022-07-16T10:47:30+00:00 Subject: [ruby-core:109230] [Ruby master Bug#18909] ARGF.readlines reads more than current file Issue #18909 has been updated by JohanJosefsson (Johan Josefsson). Eregon (Benoit Daloze) wrote in #note-11: > My two cents, options like `-i`/`-n`/`-p` shouldn't be used, I think they are vestigial legacy flags inherited from Perl or so. > Ruby is expressive enough, it is short enough to have an explicit `File.write`, loop, or whatever you need without needing to rely on a lot of magic with these old flags (which make the logic unreadable). > > ARGF is well established as being the concatenation of all such files, there is no chance to change that. 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. Maybe I am fishing in the wrong pond/barking up the wrong tree/fighting windmills but I really like this as a relative newcomer. In my view, it is here that ruby outperforms the competition and it has been the reason for me not to go with more mainstream alternatives. ---------------------------------------- Bug #18909: ARGF.readlines reads more than current file https://bugs.ruby-lang.org/issues/18909#change-98366 * 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: