nobu.nokada / softhome.net wrote: > Hi, > > $ ruby -roptparse -e 'ARGV.options{|opt|opt.def_option("-dDIR"){|d|@dir=d};opt.parse!};p self' -- -d here > #<Object:0x401938e4 @dir="here"> > Ok, it's a version issue. I'm running 1.6.8, and downloaded optparse=0.10.1 from RAA, because I though that would be the latest version. I got: ./opttest.rb -i library -n #<Object:0x200a3670 @exec=false, @inplace=""> ARGV = library Later I discovered that the version include with the 1.6-1.8 shim is actually newer! That version is alright. >>2. If you use the recommended form: >>ARGV.options do |opts| >>.... >> opts.parse! >>end >>then optparse stops command line processing, but continues with >>the script. This is also quite wrong. It should _not_ catch the exception >>(I can do that myself if I want to). Default beheviour for erroneous >>options should be exception. The programmer can put a Usage in the >>rescue. > > > parse! outside ARGV.options block. > Yes, that helps. My problem was that I followed the example opttest.rb from optparse-0.10.1. I ended up doing ARGV.options do |opts| ...... end || exit which also worked fine. The default should be to stop processing, however. Anyway, optparse is quite nice, once you've discovered how to use it. Cheers, Han Holl