ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:90239] [Ruby trunk Bug#15371] IRB with ARGV
       [not found] <redmine.issue-15371.20181203033638@ruby-lang.org>
@ 2018-12-03  3:36 ` svnpenn
  2018-12-03 17:20 ` [ruby-core:90267] " shevegen
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: svnpenn @ 2018-12-03  3:36 UTC (permalink / raw)
  To: ruby-core

Issue #15371 has been reported by svnpenn (Steven Penny).

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

* 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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:90267] [Ruby trunk Bug#15371] IRB with ARGV
       [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
  2018-12-03 19:25 ` [ruby-core:90268] " svnpenn
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: shevegen @ 2018-12-03 17:20 UTC (permalink / raw)
  To: ruby-core

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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:90268] [Ruby trunk Bug#15371] IRB with ARGV
       [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 ` [ruby-core:90267] " shevegen
@ 2018-12-03 19:25 ` svnpenn
  2019-03-22 14:19 ` [ruby-core:91936] " onlynone
  2019-08-14  2:35 ` [ruby-core:94334] [Ruby master Feature#15371] " merch-redmine
  4 siblings, 0 replies; 5+ messages in thread
From: svnpenn @ 2018-12-03 19:25 UTC (permalink / raw)
  To: ruby-core

Issue #15371 has been updated by svnpenn (Steven Penny).


shevegen (Robert A. Heiler) wrote:
> By the way, I find it slightly amusing that python's "there is only
> one way" became "there are four ways". ;-)

Its actually only 2 ways if you want a true REPL:

    $ python3 -i - alpha beta gamma
    >>> import sys
    >>> sys.argv[3]
    'gamma'

    $ python3 -i -- - alpha beta gamma
    >>> import sys
    >>> sys.argv[3]
    'gamma'

Further, looks like PRY has the same issue as RUBY:

http://github.com/pry/pry/issues/1901

Workaround is to use RIPL:

    $ ripl - alpha beta gamma
    >> ARGV[3]
    => "gamma"

    $ ripl -- alpha beta gamma
    >> ARGV[3]
    => "gamma"

http://github.com/cldwalker/ripl


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

* 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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:91936] [Ruby trunk Bug#15371] IRB with ARGV
       [not found] <redmine.issue-15371.20181203033638@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2018-12-03 19:25 ` [ruby-core:90268] " svnpenn
@ 2019-03-22 14:19 ` onlynone
  2019-08-14  2:35 ` [ruby-core:94334] [Ruby master Feature#15371] " merch-redmine
  4 siblings, 0 replies; 5+ messages in thread
From: onlynone @ 2019-03-22 14:19 UTC (permalink / raw)
  To: ruby-core

Issue #15371 has been updated by onlynone (Steven Willis).


svnpenn (Steven Penny) wrote:
> shevegen (Robert A. Heiler) wrote:
> > By the way, I find it slightly amusing that python's "there is only
> > one way" became "there are four ways". ;-)
> 
> Its actually only 2 ways if you want a true REPL:

It's actually only 1 way. The `--` is just a command line option/argument parsing convention to mark an explicit break between options and arguments. It's useful when one of your arguments might look like an option. Like if you're trying to remove a file called `-i`, you can write `rm -- -i` and the `-i` will be treated as a filename argument and not the `-i` option to ask for confirmation before deletion. It's not a python thing.

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

* 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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:94334] [Ruby master Feature#15371] IRB with ARGV
       [not found] <redmine.issue-15371.20181203033638@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2019-03-22 14:19 ` [ruby-core:91936] " onlynone
@ 2019-08-14  2:35 ` merch-redmine
  4 siblings, 0 replies; 5+ messages in thread
From: merch-redmine @ 2019-08-14  2:35 UTC (permalink / raw)
  To: ruby-core

Issue #15371 has been updated by jeremyevans0 (Jeremy Evans).

Backport deleted (2.4: UNKNOWN, 2.5: UNKNOWN)
Tracker changed from Bug to Feature

I think this is a feature request, not a bug report.  It does seem like a useful feature, so I've submitted a pull request to irb for it: https://github.com/ruby/irb/pull/22

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

* Author: svnpenn (Steven Penny)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-08-14  2:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [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 ` [ruby-core:90267] " shevegen
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

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).