]> Cypherpunks repositories - gostls13.git/commitdiff
stop flag reading before lone - arg.
authorRuss Cox <rsc@golang.org>
Wed, 19 Nov 2008 01:23:11 +0000 (17:23 -0800)
committerRuss Cox <rsc@golang.org>
Wed, 19 Nov 2008 01:23:11 +0000 (17:23 -0800)
R=r
DELTA=5  (3 added, 0 deleted, 2 changed)
OCL=19520
CL=19529

src/lib/flag.go

index 7baa72a852d5b47208104ac4740e6af5806d5caa..a1189a67fa67e5f39f9d83a3941cde6422e6ad8f 100644 (file)
@@ -32,7 +32,10 @@ package flag
  *             -flag=x
  *             -flag x
  *     One or two minus signs may be used; they are equivalent.
- *     A lone -- terminates the parsing of the command line.
+ *
+ *     Flag parsing stops just before the first non-flag argument
+ *     ("-" is a non-flag argument) or after the terminator "--".
+ *
  *     Integer flags accept 1234, 0664, 0x1234 and may be negative.
  *     Boolean flags may be 1, 0, t, f, true, false, TRUE, FALSE, True, False.
  */
@@ -397,7 +400,7 @@ func (f *Flags) ParseOne(index int) (ok bool, next int)
        }
        num_minuses := 1;
        if len(s) == 1 {
-               return false, -1
+               return false, index
        }
        if s[1] == '-' {
                num_minuses++;