fix: nested non commands trigger stack overflow

Signed-off-by: Chapman Pendery <cpendery@vt.edu>
This commit is contained in:
Chapman Pendery
2023-09-28 12:42:54 -07:00
parent 6db5eca3f1
commit 96fceb1fe2
3 changed files with 7 additions and 1 deletions
+4
View File
@@ -189,6 +189,10 @@ func handleSubcommand(tokens []commandToken, spec model.Subcommand, persistentOp
return handleSubcommand(tokens[1:], *subcommand, persistentOptions, false, false, getPersistentTokens(acceptedTokens))
}
if len(spec.Args) == 0 { // not subcommand or option & no args exist
return
}
return handleArg(tokens, spec.Args, spec, persistentOptions, acceptedTokens, false, false)
}
+1 -1
View File
@@ -28,7 +28,7 @@ func TestLoadSuggestions(t *testing.T) {
{Name: "providedArgDescription", Cmd: "act completion bash -a "},
{Name: "completedOptionWithArg", Cmd: "act completion bash -a 'actor' "},
{Name: "command", Cmd: "sudo git sta", Skip: true}, // TODO: fix skipped test
{Name: "nestedNonCommands", Cmd: "az az ", Skip: true}, // TODO: fix skipped test
{Name: "nestedNonCommands", Cmd: "az az "},
}
for _, test := range tests {
test := test