[#9722] Kernel#system broken inside Dir.chdir(&block) if system command doesn't have shell characters — <noreply@...>

Bugs item #7278, was opened at 2006-12-14 13:59

8 messages 2006/12/14

[#9749] System V IPC in standard library? — Steven Jenkins <steven.jenkins@...>

Back in August, I needed a semaphore to serialize access to an external

14 messages 2006/12/19

[#9753] CVS freeze — SASADA Koichi <ko1@...>

Hi,

20 messages 2006/12/20
[#9755] Re: [ruby-dev:30039] CVS freeze — SASADA Koichi <ko1@...> 2006/12/20

Hi,

[#9757] Re: [ruby-dev:30040] Re: CVS freeze — SASADA Koichi <ko1@...> 2006/12/20

Hi,

using OptionParser.on_tail leads to missed AmbiguousOption

From: Jim Meyering <list+ruby@...>
Date: 2006-12-10 19:35:55 UTC
List: ruby-core #9696
From a quick look at ruby1.9's optparse.rb, it seems options registered
via on_tail (and maybe on_head, too?) are not searched when determining
whether to throw an AmbiguousOption.  This is ruby1.9 from Debian/unstable.

For example, given this code, handling both --version and --verbose,
I would expect the use of a "--v" argument to evoke an AmbiguousOption:

    #!/usr/bin/ruby
    require 'optparse'
    require 'ostruct'
    class OptparseExample
      def self.parse(args)
        options = OpenStruct.new
        opts = OptionParser.new do |opts|
          opts.on     ("--verbose", "be verbose")     do puts "verbose" end
          opts.on_tail("--version", "output version") do puts "version" end
        end
        opts.parse!(args)
        options
      end
    end
    options = OptparseExample.parse(ARGV)

Yet I get this:

    $ ruby1.9 optparse --v
    verbose

However, if I transform the code via s/on_tail/on/, it works the way I want:

    $ ruby1.9 optparse --v
    /usr/lib/ruby/1.9/optparse.rb:1488:in `complete': ambiguous option: --v (OptionParser::AmbiguousOption)
            from /usr/lib/ruby/1.9/optparse.rb:1316:in `order!'
            from /usr/lib/ruby/1.9/optparse.rb:1309:in `order!'
            from /usr/lib/ruby/1.9/optparse.rb:1396:in `permute!'
            from /usr/lib/ruby/1.9/optparse.rb:1423:in `OptionParser#parse!'
            from optparse:11:in `OptparseExample#parse'
            from optparse:15
    [Exit 1]

In This Thread

Prev Next