From 1c59156833d8875266c57edf049707b34d52bb97 Mon Sep 17 00:00:00 2001 From: rsteube Date: Mon, 17 Jul 2023 10:21:48 +0200 Subject: [PATCH] traverse: fix shorthand flagseries check - fix `go tool cover -f` => `error: unknown shorthand flag: -f` --- traverse.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/traverse.go b/traverse.go index f689e765..b53145b4 100644 --- a/traverse.go +++ b/traverse.go @@ -115,7 +115,7 @@ loop: if inFlag != nil && len(inFlag.Args) == 0 && inFlag.Consumes("") { LOG.Printf("removing arg %#v since it is a flag missing its argument\n", toParse[len(toParse)-1]) toParse = toParse[:len(toParse)-1] - } else if fs.IsShorthandSeries(context.Value) { + } else if (fs.IsInterspersed() || len(inPositionals) == 0) && fs.IsShorthandSeries(context.Value) { LOG.Printf("arg %#v is a shorthand flag series", context.Value) localInFlag := &_inFlag{ Flag: fs.LookupArg(context.Value),