Project

General

Profile

Backport #7157

Ruby ignores Kernel#gsub block

Added by popoxee (Bruce Metz) almost 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:47967]

Description

When working with command line and use Kernel#gsub, ruby ignores the block if given.

Reproduce code:

Test text file:
File name:
test
File Content:
test

Test Command line input:

ruby -pe 'gsub(/t([a-z])s/){"d"+$1.capitalize}' test

Expected output:

dEt

Actual output:

#Enumerator:0x00000001c78520

Associated revisions

Revision 9e02550b
Added by nobu (Nobuyoshi Nakada) almost 7 years ago

ruby.c: passing block

  • ruby.c (rb_f_sub, rb_f_gsub): pass the given block. [ruby-core:47967] [Bug #7157]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 37177
Added by nobu (Nobuyoshi Nakada) almost 7 years ago

ruby.c: passing block

  • ruby.c (rb_f_sub, rb_f_gsub): pass the given block. [ruby-core:47967] [Bug #7157]

Revision 37177
Added by nobu (Nobuyoshi Nakada) almost 7 years ago

ruby.c: passing block

  • ruby.c (rb_f_sub, rb_f_gsub): pass the given block. [ruby-core:47967] [Bug #7157]

Revision 37177
Added by nobu (Nobuyoshi Nakada) almost 7 years ago

ruby.c: passing block

  • ruby.c (rb_f_sub, rb_f_gsub): pass the given block. [ruby-core:47967] [Bug #7157]

Revision 37177
Added by nobu (Nobuyoshi Nakada) almost 7 years ago

ruby.c: passing block

  • ruby.c (rb_f_sub, rb_f_gsub): pass the given block. [ruby-core:47967] [Bug #7157]

Revision 37177
Added by nobu (Nobuyoshi Nakada) almost 7 years ago

ruby.c: passing block

  • ruby.c (rb_f_sub, rb_f_gsub): pass the given block. [ruby-core:47967] [Bug #7157]

Revision 37177
Added by nobu (Nobuyoshi Nakada) almost 7 years ago

ruby.c: passing block

  • ruby.c (rb_f_sub, rb_f_gsub): pass the given block. [ruby-core:47967] [Bug #7157]

Revision 259d9dbc
Added by usa (Usaku NAKAMURA) almost 7 years ago

merge revision(s) 37177: [Backport #7157]

    * ruby.c (rb_f_sub, rb_f_gsub): pass the given block.
      [ruby-core:47967] [Bug #7157]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@37205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 37205
Added by usa (Usaku NAKAMURA) almost 7 years ago

merge revision(s) 37177: [Backport #7157]

* ruby.c (rb_f_sub, rb_f_gsub): pass the given block.
  [ruby-core:47967] [Bug #7157]

History

Updated by zzak (Zachary Scott) almost 7 years ago

The docs for Kernel#gsub mention:
"Equivalent to $.gsub..., except that $ receives the modified
result. Available only when -p/-n command line option specified."

On Sat, Oct 13, 2012 at 8:14 PM, popoxee (Bruce Metz)
popoxee@hotmail.com wrote:

Issue #7157 has been reported by popoxee (Bruce Metz).


Bug #7157: Ruby ignores Kernel#gsub block
https://bugs.ruby-lang.org/issues/7157

Author: popoxee (Bruce Metz)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-linux]

When working with command line and use Kernel#gsub, ruby ignores the block if given.

Reproduce code:

Test text file:
File name:
test
File Content:
test

Test Command line input:

ruby -pe 'gsub(/t([a-z])s/){"d"+$1.capitalize}' test

Expected output:

dEt

Actual output:

#Enumerator:0x00000001c78520

--
http://bugs.ruby-lang.org/

#2

Updated by nobu (Nobuyoshi Nakada) almost 7 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r37177.
Bruce, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


ruby.c: passing block

  • ruby.c (rb_f_sub, rb_f_gsub): pass the given block. [ruby-core:47967] [Bug #7157]
#3

Updated by nobu (Nobuyoshi Nakada) almost 7 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport193
  • Status changed from Closed to Assigned
  • Assignee set to usa (Usaku NAKAMURA)
#4

Updated by usa (Usaku NAKAMURA) almost 7 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r37205.
Bruce, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 37177: [Backport #7157]

* ruby.c (rb_f_sub, rb_f_gsub): pass the given block.
  [ruby-core:47967] [Bug #7157]

Also available in: Atom PDF