rust-lang/getopts — pull request #2 by ltratt (2014-12-29 18:28:49+00:00)
Title: Stop parsing arguments as soon as something that is obviously not a flag is hit

eAt the moment, getopts parses a command like (NB: ignoring the program name of
the comand being run) "a -b c" as having opts={"-b":"c"} and free=["a"]. If
instead one does "-- a -b c" one gets opts={} and free=["a", "-b", -"]. However,
the former behaviour doesn't match what Unix's getopts does which confused me.

For example a Unix command like:

$ find . | xargs ls -l

prints out the long version of every file that find prints, even without
explicitly using "--" with xargs. While this implicitness may or may not be a
good idea, subverting this expectation confuses old farts like me.

This patch therefore makes the getopts crate parse a command line "a -b c" is
parsed as having opts={} and free=["a", "-b", "c"].