From: csaba@... Date: 2021-08-09T23:21:06+00:00 Subject: [ruby-core:104857] [Ruby master Bug#18074] ARGF.read(length) exhibits short rea Issue #18074 has been updated by csabahenk2 (Csaba Henk). It was commit [4f5976c](https://github.com/ruby/ruby/commit/4f5976cbb826df462c62a0a8e72ebe91c15a7ba4) that introduced this bug: ``` commit 4f5976cbb826df462c62a0a8e72ebe91c15a7ba4 Author: matz Date: Wed Dec 3 17:30:09 2003 +0000 * io.c (argf_read): should not terminate on empty string; wait until real EOF. [ruby-dev:21969] * io.c (argf_read): should adjust length to read, when length is specified and read spans command line argument files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e ``` _4f5976c_ is _v1_8_1~189_, so practically all MRI versions are affected. ---------------------------------------- Bug #18074: ARGF.read(length) exhibits short rea https://bugs.ruby-lang.org/issues/18074#change-93205 * Author: csabahenk2 (Csaba Henk) * Status: Open * Priority: Normal * ruby -v: ruby 3.1.0dev (2021-08-04T09:29:42Z master 6e55facdb3) [x86_64-linux] * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- If ruby is invoked with three file name arguments (which refer to extant non-empty regular files), and `ARFG.read` is called with a length argument that exceeds the combined size of the first two files[1], then only the content of the first two files will be collected in the resultant string. ``` shell $ for f in a b c; do echo -n $f > $f; done $ ruby -e 'p ARGF.read(3)' a b c "ab" ``` [1]: This is actually just a necessary condition, the exact criteria will be provided in followup analysis. -- https://bugs.ruby-lang.org/ Unsubscribe: