OptionParser on option separator "--"

Hi all!

Does anyone here know if it is on purpose that OptionParser#parse!
eats option separators “–”. For example:

require "optparse"
opts = OptionParser.new
opts.parse(%w{hello -- world})
# => ["hello", "world"]

Bug or feature? If feature, any use case for that ??

Thanks a lot!
Bernard

It’s standard option parsing behaviour. – indicates “end of options”,
and is important if any of the subsequent parameters otherwise looks
like an option.

require “optparse”
opts = OptionParser.new
p opts.parse(%w{hello – world --flurble --boing})

=> [“hello”, “world”, “–flurble”, “–boing”]

p opts.parse(%w{hello world --flurble --boing})

invalid option: flurble

Also, quoting from the getopt(1) manpage:

"Each parameter not starting with a -', and not a required argument of a previous option, is a non-option parameter. Each parameter after a–’ parameter is always interpreted as a non-option parameter.

Whoups, I did not know that there was a commonly agreed
specification for that… I’ll have a deeper look at that man page.

Brian, thanks a lot!
B