summaryrefslogtreecommitdiffstats
path: root/vtysh
diff options
context:
space:
mode:
authorRafael Zalamena <rzalamena@users.noreply.github.com>2021-06-07 13:32:31 +0200
committerGitHub <noreply@github.com>2021-06-07 13:32:31 +0200
commit4548fb256c31e0c9e7e913e8dc110934d7c0d79a (patch)
treedca46163795e8e6bb1a2ca2dae4747122cdc240a /vtysh
parentMerge pull request #8756 from volta-networks/ospfd_sr_blocks (diff)
parentlib: fix output of "list" and "find" commands (diff)
downloadfrr-4548fb256c31e0c9e7e913e8dc110934d7c0d79a.tar.xz
frr-4548fb256c31e0c9e7e913e8dc110934d7c0d79a.zip
Merge pull request #8781 from idryzhov/fix-list-find
lib: fix output of "list" and "find" commands
Diffstat (limited to 'vtysh')
-rw-r--r--vtysh/vtysh.c74
1 files changed, 1 insertions, 73 deletions
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index e8184c2dc..a50dccbda 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -3729,79 +3729,7 @@ DEFUN(find,
"Find CLI command matching a regular expression\n"
"Search pattern (POSIX regex)\n")
{
- const struct cmd_node *node;
- const struct cmd_element *cli;
- vector clis;
- regex_t exp = {};
- char *pattern = argv_concat(argv, argc, 1);
- int cr = regcomp(&exp, pattern, REG_NOSUB | REG_EXTENDED);
-
- XFREE(MTYPE_TMP, pattern);
-
- if (cr != 0) {
- switch (cr) {
- case REG_BADBR:
- vty_out(vty, "%% Invalid \\{...\\} expression\n");
- break;
- case REG_BADRPT:
- vty_out(vty, "%% Bad repetition operator\n");
- break;
- case REG_BADPAT:
- vty_out(vty, "%% Regex syntax error\n");
- break;
- case REG_ECOLLATE:
- vty_out(vty, "%% Invalid collating element\n");
- break;
- case REG_ECTYPE:
- vty_out(vty, "%% Invalid character class name\n");
- break;
- case REG_EESCAPE:
- vty_out(vty,
- "%% Regex ended with escape character (\\)\n");
- break;
- case REG_ESUBREG:
- vty_out(vty,
- "%% Invalid number in \\digit construction\n");
- break;
- case REG_EBRACK:
- vty_out(vty, "%% Unbalanced square brackets\n");
- break;
- case REG_EPAREN:
- vty_out(vty, "%% Unbalanced parentheses\n");
- break;
- case REG_EBRACE:
- vty_out(vty, "%% Unbalanced braces\n");
- break;
- case REG_ERANGE:
- vty_out(vty,
- "%% Invalid endpoint in range expression\n");
- break;
- case REG_ESPACE:
- vty_out(vty, "%% Failed to compile (out of memory)\n");
- break;
- }
-
- goto done;
- }
-
-
- for (unsigned int i = 0; i < vector_active(cmdvec); i++) {
- node = vector_slot(cmdvec, i);
- if (!node)
- continue;
- clis = node->cmd_vector;
- for (unsigned int j = 0; j < vector_active(clis); j++) {
- cli = vector_slot(clis, j);
-
- if (regexec(&exp, cli->string, 0, NULL, 0) == 0)
- vty_out(vty, " (%s) %s\n",
- node->name, cli->string);
- }
- }
-
-done:
- regfree(&exp);
- return CMD_SUCCESS;
+ return cmd_find_cmds(vty, argv, argc);
}
DEFUN_HIDDEN(show_cli_graph_vtysh,