GetoptLong problem

Hi all,

Learning ruby on my debian with ruby 1.6.8, I try the following test program:

#!/usr/bin/env ruby

require ‘getoptlong’

opts = GetoptLong.new(
[ “–size”, “-s”, GetoptLong::REQUIRED_ARGUMENT ],
[ “–verbose”, “-v”, GetoptLong::NO_ARGUMENT ],
[ “–term”, “-t”, GetoptLong::NO_ARGUMENT ],
[ “–query”, “-q”, GetoptLong::NO_ARGUMENT ],
[ “–check”, “–valid”, “-c”, GetoptLong::NO_ARGUMENT ]
)

puts opts
opts.each do |opt, arg|
puts “Option: #{opt}, arg #{arg.inspect}”
opts.terminate if (opt == ‘–term’)
end

puts “Remaining args: #{ARGV.join(’, ')}”

Well it works fine if I used options foreseen by programmer. But it failled
as soon as used another (faulty) option:

for exanple ruby opt-tst.rb --imho

I am awaiting: ‘Remaining args: --imho’

OTC getoptlong.rb failed with following message:
opt1.rb: unrecognized option --imho' /usr/lib/ruby/1.6/getoptlong.rb:230:in set_error’: unrecognized option
--imho' (GetoptLong::InvalidOption) from /usr/lib/ruby/1.6/getoptlong.rb:321:in get’
from /usr/lib/ruby/1.6/getoptlong.rb:409:in each' from /usr/lib/ruby/1.6/getoptlong.rb:409:in loop’
from /usr/lib/ruby/1.6/getoptlong.rb:409:in `each’
from opt1.rb:14
#GetoptLong:0x4037ab20

Do you thing that is a bug solved in 1.7?

Does it exist a work around (awaiting 1.7 available on my distro)?

Thanks in advance for help,
Joel

PS: The joined SplitPatch.rb is the actual script on which I encounter first
the problem.

SplitPatch.rb (4.14 KB)

···

Promo Tiscali ADSL: 35 Euros/mois, 1er mois et activation = 0 Euro http://adsl.tiscali.be