summaryrefslogtreecommitdiff
path: root/src/lib/flag.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2008-11-18 17:23:11 -0800
committerRuss Cox <rsc@golang.org>2008-11-18 17:23:11 -0800
commit0a4eee9f64d1d8be490ec218a9edb9a363b888e1 (patch)
tree79540e5236c999b424d4da780211a0a9cedc328d /src/lib/flag.go
parentdadfd9070489ffa1947e9d62c2c01af8527be744 (diff)
downloadgolang-0a4eee9f64d1d8be490ec218a9edb9a363b888e1.tar.gz
stop flag reading before lone - arg.
R=r DELTA=5 (3 added, 0 deleted, 2 changed) OCL=19520 CL=19529
Diffstat (limited to 'src/lib/flag.go')
-rw-r--r--src/lib/flag.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lib/flag.go b/src/lib/flag.go
index 7baa72a85..a1189a67f 100644
--- a/src/lib/flag.go
+++ b/src/lib/flag.go
@@ -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++;