Keep empty and dash operands with runnable parents
This commit is contained in:
@@ -408,7 +408,10 @@ func flagUsage(flag commandmeta.Flag) string {
|
||||
|
||||
func splitRoutingPrefix(argv []string) ([]string, []string) {
|
||||
for index, argument := range argv {
|
||||
if argument == "--" || (strings.HasPrefix(argument, "-") && argument != "-") {
|
||||
// Empty strings and "-" can be operands but never command names.
|
||||
// Keep them out of Find, which could skip them and select a child
|
||||
// from a later operand instead of retaining the runnable parent.
|
||||
if argument == "" || strings.HasPrefix(argument, "-") {
|
||||
return commandpath.CloneTokens(argv[:index]), commandpath.CloneTokens(argv[index:])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user