2008/2/20, 7stud -- <bbxx789_05ss / yahoo.com>: > I see several problems with that solution: > 2) It uses the try/except mechanism which slows down your program when a > exception actually occurs. Options are only parsed once per invocation. The exception time is easily dominated by process exec time and the runtime of the wrapped program. > 3) The fact that an option might not be a wrapper option is not an > exceptional event--you regularly expect that to be the case. Well, but from OptionParser's perspective it *is* an exception: the option is unkown to OptionParser and hence it cannot process properly. I do agree though that it is a bit odd, especially considering that all other options still are parsed properly which might not necessarily be expected (I would expect OptionParser to bail out at the first unknown option by default). > Problems with that solution: > > I'm not thrilled with the code that deletes elements out of ARGV--that's > inefficient because the rest of the elements have to be shuffled over > one spot. On the other hand, if I collect all the desired options into > an array and then assign the array to ARGV, I get a warning: > > warning: already initialized constant ARGV Another issue I see with your solution is that you might run into problems because you remove items from a collection that is being iterated over. That's usually unsafe. This on is a bit artificial: by using ARGV.index to find an option your code assumes that OptionParser will process options left to right. If it chooses a different approach you might end up deleting the wrong instance of a duplicated option. Kind regards robert -- use.inject do |as, often| as.you_can - without end