diff --git a/lib/command_match.c b/lib/command_match.c
index e75910c272..13c890fc03 100644
--- a/lib/command_match.c
+++ b/lib/command_match.c
@@ -27,6 +27,7 @@
#include "command_match.h"
#include "memory.h"
+
#ifdef TRACE_MATCHER
#define TM 1
#else
@@ -362,7 +363,8 @@ command_complete (struct graph *graph,
input_token, token->text, token->type);
unsigned int last_token = (vector_active (vline) - 1 == idx);
- switch (match_token (token, input_token))
+ enum match_type matchtype = match_token (token, input_token);
+ switch (matchtype)
{
// occurs when last token is whitespace
case trivial_match:
@@ -378,7 +380,7 @@ command_complete (struct graph *graph,
trace_matcher ("exact_match\n");
if (last_token)
listnode_add (next, gn);
- else
+ else if (matchtype >= minmatch)
add_nexthops (next, gn);
break;
default:
diff --git a/tests/test-cli.c b/tests/test-cli.c
index e7bed0991e..0590eec713 100644
--- a/tests/test-cli.c
+++ b/tests/test-cli.c
@@ -30,7 +30,6 @@ DUMMY_DEFUN(cmd2, "arg ipv6 X:X::X:X");
DUMMY_DEFUN(cmd3, "arg ipv6m X:X::X:X/M");
DUMMY_DEFUN(cmd4, "arg range (5-15)");
DUMMY_DEFUN(cmd5, "pat a < a|b>");
-DUMMY_DEFUN(cmd6, "pat b ");
DUMMY_DEFUN(cmd7, "pat c A.B.C.D");
DUMMY_DEFUN(cmd8, "pat d { foo A.B.C.D|bar X:X::X:X| baz }");
DUMMY_DEFUN(cmd9, "pat e [ WORD ]");
@@ -47,7 +46,6 @@ void test_init(void)
install_element (ENABLE_NODE, &cmd3_cmd);
install_element (ENABLE_NODE, &cmd4_cmd);
install_element (ENABLE_NODE, &cmd5_cmd);
- install_element (ENABLE_NODE, &cmd6_cmd);
install_element (ENABLE_NODE, &cmd7_cmd);
install_element (ENABLE_NODE, &cmd8_cmd);
install_element (ENABLE_NODE, &cmd9_cmd);
diff --git a/tests/testcli.in b/tests/testcli.in
index f4212b9758..5c146ef984 100644
--- a/tests/testcli.in
+++ b/tests/testcli.in
@@ -50,11 +50,6 @@ pat a ?b
pat a c?
pat a a x
-pat b
-pat b ?a
-pat b x
-pat b x y
-
pat c a
pat c a 1.2.3.4
pat c b 2.3.4
diff --git a/tests/testcli.refout b/tests/testcli.refout
index 816227579b..922a620ce6 100644
--- a/tests/testcli.refout
+++ b/tests/testcli.refout
@@ -1,8 +1,7 @@
test# echo this is a test message
this is a test message
test# echo foo bla
- MESSAGE The message to echo
-
+% There is no matched command.
test# echo foo bla baz
foo bla baz
test# echo
@@ -116,7 +115,7 @@ cmd4 with 3 args.
[01]: range
[02]: 5
test# arg range 9
- <5-15> 02
+ (5-15) 02
test# arg range 9
cmd4 with 3 args.
[00]: arg
@@ -147,7 +146,7 @@ test# pa
test# papat
% Command incomplete.
test# pat
-a b c d e f
+a c d e f
test# pat
% Command incomplete.
test#
@@ -173,18 +172,6 @@ test# pat a c
test# pat a a x
% [NONE] Unknown command: pat a a x
test#
-test# pat b
-% Command incomplete.
-test# pat b
- a 02
-test# pat b a
-cmd6 with 1 args.
-[00]: a
-test# pat b x
-% [NONE] Unknown command: pat b x
-test# pat b x y
-% [NONE] Unknown command: pat b x y
-test#
test# pat c a
% Command incomplete.
test# pat c a 1.2.3.4
@@ -194,9 +181,7 @@ cmd7 with 4 args.
[02]: a
[03]: 1.2.3.4
test# pat c b 2.3.4
-cmd7 with 2 args.
-[00]: b
-[01]: 2.3.4
+% [NONE] Unknown command: pat c b 2.3.4
test# pat c c
A.B.C.D 05
test# pat c c x