diff options
| author | Andy Goldstein <[email protected]> | 2015-01-26 16:18:00 -0500 |
|---|---|---|
| committer | Andy Goldstein <[email protected]> | 2015-02-17 20:24:54 -0500 |
| commit | f160cd4dadf5efaabbeecea67ad3486a452ab72b (patch) | |
| tree | 962e5398db836210679537773d6430b3ad574165 /flag.go | |
| parent | f82776d6cc998e3c026baef7b24409ff49fe5c8d (diff) | |
Fix handling of -- termination
Fix handling of -- termination. Previously, if you ran
$command -flag1 -etc -- some args after
the command's args would be doubled (some args after some args after).
Additionally, if there were items after the -- termination that looked
like flags, the parser would throw an error. It's better to terminate
parsing when -- is seen, because that usually indicates the caller wants
to pass the remainder of the arguments (including flags) as-is to
something else.
Diffstat (limited to 'flag.go')
| -rw-r--r-- | flag.go | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -543,6 +543,11 @@ func (f *FlagSet) parseArgs(args []string) (err error) { if s[1] == '-' { args, err = f.parseLongArg(s, args) + + if len(s) == 2 { + // stop parsing after -- + break + } } else { args, err = f.parseShortArg(s, args) } |
