Project

General

Profile

Actions

Bug #14162

closed

Invoking binding.irb destructively shifts ARGV

Added by k0kubun (Takashi Kokubun) almost 7 years ago. Updated almost 7 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 2.5.0dev (2017-12-05 trunk 61034) [x86_64-linux]
[ruby-core:84135]

Description

$ ruby -v
ruby 2.5.0dev (2017-12-05 trunk 61034) [x86_64-linux]
$ cat script.rb
binding.irb
binding.irb
$ ruby script.rb a b c

From: script.rb @ line 1 :

 => 1: binding.irb
    2: binding.irb

irb(main):001:0> p ARGV
["b", "c"]
=> ["b", "c"]
irb(main):002:0>

From: script.rb @ line 2 :

    1: binding.irb
 => 2: binding.irb

irb(main):001:0> p ARGV
["c"]
=> ["c"]

Is this intentional? This is reproductive on both Ruby 2.4 and 2.5.

Updated by k0kubun (Takashi Kokubun) almost 7 years ago

Also, the shifted value becomes $0 (and @CONF[:SCRIPT]).

I guessed they are not intentional and created a patch that skips parsing ARGV for binding.irb https://github.com/ruby/ruby/pull/1770.

Actions #2

Updated by k0kubun (Takashi Kokubun) almost 7 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r61149.


irb.rb: preserve ARGV on binding.irb

This is not perfectly good solution (at least we don't want to have ARGV
as default value of argv argument), but unfortunately IRB.setup and
IRB.parse_opts are public methods and we can't make breaking change to
those methods.

We may deprecate using them and then make them private in the future,
but the removal should not be in Ruby 2.5. So I kept their interface for
now.

[Bug #14162] [close GH-1770]

Updated by nagachika (Tomoyuki Chikanaga) almost 7 years ago

  • Backport changed from 2.3: DONTNEED, 2.4: REQUIRED to 2.3: DONTNEED, 2.4: DONE

ruby_2_4 r62185 merged revision(s) 61149,61150,61151,61167.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0