From: Patrick Bennett Date: 2002-07-31T15:31:51+09:00 Subject: Re: Question about GetoptLong > > >Then, in the sample I gave earlier, I added the following: > > not_handled = [] > opts.each do |opt, arg| > case opt > ## We handle log > when "--log" > puts "parsing: #{opt}: #{arg}" > ## We pass cc > else > ## Unknown option (probably need some error checking here) > not_handled << [opt, arg] > end#case > end#each > >When your done, add the not_handled array back to ARGV > > ARGV.unshift(not_handled).flatten! > > > Reasonable idea, but.... it still won't work since GetoptLong (wrongly so IMO) raises an exception whenever it sees something it doesn't understand, as well as eating the 'non-option' it just parsed - which in my case would most likely be an option somebody else is going to care about! If you could defeat GetoptLong's desire to raise an exception (and eat the option/non-option from ARGV) on every thing it didn't understand, then something 'might' be workable. Either way, it's frustrating to have something be so trivial in Perl, yet be a major PITA in Ruby. *sigh* (in global settings) Getopt::Long::Configure(pass_through, no_auto_abbrev); GetOptions('logfile' => \$logfile, 'log' => \$log, 'leave_tempfiles' => \$leave_tempfiles, 'batch_length=i' => \$batch_length); Getopt::Long::Configure(no_pass_through, auto_abbrev); (in 'one' of the local commands) GetOptions('v' => \$integ_option_v, 'quiet' => \$quiet, 'noop' => \$noop, 'force' => \$force, 'team_project=s' => \$team_project); [note that it supports 'types' for options with arguments as well] If I was a more experienced Ruby programmer, I might look at fixing GetoptLong, but right now, I'm just trying to port a working Perl script, and I'm running into some unexpected roadblocks over things I thought would be a non-issue. :<