Only delete arg when it is not starts with -

Signed-off-by: JaySon-Huang <tshent@qq.com>
This commit is contained in:
JaySon-Huang 2021-12-03 02:53:30 +08:00
parent a916286db1
commit d364ed0157
No known key found for this signature in database
GPG key ID: 370C14C8CDC7A5ED

View file

@ -585,11 +585,12 @@ Loop:
case strings.HasPrefix(s, "-") && !strings.Contains(s, "=") && len(s) == 2 && !shortHasNoOptDefVal(s[1:], flags):
// If '-f arg' then
// delete 'arg' from args or break the loop if len(args) <= 1.
if len(args) <= 1 {
if len(args) == 0 {
break Loop
} else {
}
// Only delete 'arg' when it is not starts with '-'
if !strings.HasPrefix(args[0], "-") {
args = args[1:]
continue
}
case s != "" && !strings.HasPrefix(s, "-"):
commands = append(commands, s)