diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index d265f2a83..4caecd787 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -4901,7 +4901,7 @@ void Interpreter::ProcessLine(char *aBuf) ExitNow(); } - SuccessOrExit(ProcessUserCommands(argsLength, args)); + VerifyOrExit(ProcessUserCommands(argsLength, args) != OT_ERROR_NONE); OutputResult(OT_ERROR_INVALID_COMMAND); exit: diff --git a/tests/scripts/expect/cli-misc.exp b/tests/scripts/expect/cli-misc.exp index 6b548e0c8..af6fb22ce 100755 --- a/tests/scripts/expect/cli-misc.exp +++ b/tests/scripts/expect/cli-misc.exp @@ -173,4 +173,7 @@ expect "Done" send "ba state\n" expect "Done" +send "invalidcommand\n" +expect_line "Error 35: InvalidCommand" + dispose_all