Project

General

Profile

Actions

Bug #2020

closed

ARGF.lineno and $. give inconsistent results

Added by telemachus (Peter Aronoff) about 15 years ago. Updated over 13 years ago.

Status:
Closed
Assignee:
-
ruby -v:
ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-darwin9.7.1]
[ruby-core:25205]

Description

=begin
When using ARGF on Ruby 1.9.1 (rev. 24175), ARGF.lineno gives a result of '0' for all lines. $. works as expected.

This script shows the problem:

#!/usr/bin/env ruby -w

ARGF.each do |line|
print "With [lineno]:\t"
print ARGF.lineno, ': ', line
print "With [$.]:\t"
print $., ': ', line
end

If I run this with Ruby 1.8.6 (OS X's system Ruby), the output from $. and ARGF.lineno is identical. With 1.9.1, I get this:

telemachus ~ $ ./cat.rb test.txt
With [lineno]: 0: This is line one.
With [$.]: 1: This is line one.
With [lineno]: 0: Here is line two.
With [$.]: 2: Here is line two.
With [lineno]: 0: A third line for fun.
With [$.]: 3: A third line for fun.

Thanks, T
=end


Files

argf-lineno.diff (1.92 KB) argf-lineno.diff fix ARGF.lineno znz (Kazuhiro NISHIYAMA), 01/22/2010 03:03 PM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #3022: What are $. and ARGF.lineno ?Closeddrbrain (Eric Hodel)03/27/2010Actions
Actions #1

Updated by znz (Kazuhiro NISHIYAMA) almost 15 years ago

=begin
I reproduced on ruby 1.9.2dev (2010-01-22 trunk 26370) [x86_64-linux] too.
And I think an attached patch fixes the problem on trunk.

=end

Actions #2

Updated by marcandre (Marc-Andre Lafortune) over 14 years ago

  • Status changed from Open to Closed

=begin
Patch applied in r27308
Peter, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0