ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: shevegen@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:90267] [Ruby trunk Bug#15371] IRB with ARGV
Date: Mon, 03 Dec 2018 17:20:44 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-75382.20181203172042.846f314f3b9772d6@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15371.20181203033638@ruby-lang.org

Issue #15371 has been updated by shevegen (Robert A. Heiler).


I can not say whether the above is a bug or not; however had a grep
shows that there are two toplevel methods for IRB to make use
of ARGV, both in init.rb:

    init.rb:  def IRB.setup(ap_path, argv: ::ARGV)
    init.rb:  def IRB.parse_opts(argv: ::ARGV)

By the way, I find it slightly amusing that python's "there is only
one way" became "there are four ways". ;-)

----------------------------------------
Bug #15371: IRB with ARGV
https://bugs.ruby-lang.org/issues/15371#change-75382

* Author: svnpenn (Steven Penny)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
PHP allows you to pass ARGV in interactive mode:

    $ php -a -- alpha beta gamma
    php > print $argv[3] . PHP_EOL;
    gamma

and Python offers 4 ways:

    $ python3 - alpha beta gamma
    >>> import sys
    >>> print(sys.argv[3])
    gamma

    $ python3 -- - alpha beta gamma
    >>> import sys
    >>> print(sys.argv[3])
    gamma

    $ python3 -i - alpha beta gamma
    >>> import sys
    >>> print(sys.argv[3])
    gamma

    $ python3 -i -- - alpha beta gamma
    >>> import sys
    >>> print(sys.argv[3])
    gamma

However IRB seems to have no way to accomplish this:

    $ irb - alpha beta gamma
    /usr/share/ruby/2.3.0/irb/init.rb:213:in `parse_opts':
    Unrecognized switch: - (IRB::UnrecognizedSwitch)

    $ irb -- alpha beta gamma
    /usr/share/ruby/2.3.0/irb/magic-file.rb:8:in `initialize': No such file or
    directory @ rb_sysopen - alpha (Errno::ENOENT)

    $ irb -- - alpha beta gamma
    /usr/share/ruby/2.3.0/irb/magic-file.rb:8:in `initialize': No such file or
    directory @ rb_sysopen - - (Errno::ENOENT)

    $ irb - -- alpha beta gamma
    /usr/share/ruby/2.3.0/irb/init.rb:213:in `parse_opts':
    Unrecognized switch: - (IRB::UnrecognizedSwitch)



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

  parent reply	other threads:[~2018-12-03 17:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-15371.20181203033638@ruby-lang.org>
2018-12-03  3:36 ` [ruby-core:90239] [Ruby trunk Bug#15371] IRB with ARGV svnpenn
2018-12-03 17:20 ` shevegen [this message]
2018-12-03 19:25 ` [ruby-core:90268] " svnpenn
2019-03-22 14:19 ` [ruby-core:91936] " onlynone
2019-08-14  2:35 ` [ruby-core:94334] [Ruby master Feature#15371] " merch-redmine

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-75382.20181203172042.846f314f3b9772d6@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).