Skip to content

Add ARGF — the concatenated ARGV input stream - #480

Merged
tannevaled merged 1 commit into
mainfrom
feat/argf
Aug 29, 2026
Merged

tannevaled merged 1 commit into
mainfrom
feat/argf

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

ARGF ($<) is a new virtual stream that reads the files named in ARGV
(falling back to $stdin when ARGV is empty) as one continuous input,
consuming ARGV as it goes and tracking a cumulative line number ($.).
ARGF.class.new(*files) builds a fresh stream over an explicit file list.

Implements the core reading protocol: read (with an optional length, nil past
EOF), gets / readline (EOFError at end), each_line / each (Enumerator
with no block), readlines / to_a, getc / readchar, eof?, lineno (and
lineno=), filename / path, to_io, argv, skip, close and binmode.
The seek/pos/rewind, per-byte/char iterators and set_encoding forms remain
a follow-up.

The MSpec argf helper (which binds @argf to ARGF.class.new(*files)) is added
to the conformance shim so the ARGF specs can drive it.

Verified against ruby 4.0.6. Whole-package coverage stays at 100%; the ruby/spec
ratchet floor rises 16095 → 16150 (core/argf 0 → 42, zero regressions in a
deterministic per-file sweep).

🤖 Generated with Claude Code

ARGF ($<) is a new virtual stream that reads the files named in ARGV (falling
back to $stdin when ARGV is empty) as one continuous input, consuming ARGV as it
goes and tracking a cumulative line number ($.). ARGF.class.new(*files) builds a
fresh stream over an explicit file list.

Implements the core reading protocol: read (with an optional length, nil past
EOF), gets / readline (EOFError at end), each_line / each (Enumerator with no
block), readlines / to_a, getc / readchar, eof?, lineno (and lineno=),
filename / path, to_io, argv, skip, close and binmode. The seek/pos/rewind,
per-byte/char iterators and set_encoding forms remain a follow-up.

The MSpec `argf` helper (which binds @argf to ARGF.class.new(*files)) is added to
the conformance shim so the ARGF specs can drive it.

Verified against ruby 4.0.6. Whole-package coverage stays at 100%; the ruby/spec
floor rises 16095 -> 16150 (core/argf 0 -> 42).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit e400f0f into main Aug 29, 2026
7 checks passed
@tannevaled
tannevaled deleted the feat/argf branch August 29, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant