aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2020-05-15 16:12:23 +0200
committerAndrew Yourtchenko <ayourtch@gmail.com>2020-08-18 19:47:21 +0000
commit449f50555d55e4bb0e322603f4bc19524bb0d0c7 (patch)
treea1135dc1c6c76390ccc20568933eb1905660c9ae /src
parentb1a7f68b220ebc8d2de7128dae7b471fd4e46873 (diff)
vlib: restore commands for non-interactive sessions
'quit' and 'show terminal' are valid for non-interactive sessions too. Type: fix Fixes: a58be82dda89d6496f92e451b42eee31f0cf47b4 Change-Id: Ib63244c7b64ad2e30c257ed19e982295f59bfffa Signed-off-by: Benoît Ganne <bganne@cisco.com> (cherry picked from commit 10a22a629468b18f5b07316980e2761285283939)
Diffstat (limited to 'src')
-rw-r--r--src/vlib/unix/cli.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/vlib/unix/cli.c b/src/vlib/unix/cli.c
index b7acba189c9..f6daf928ef5 100644
--- a/src/vlib/unix/cli.c
+++ b/src/vlib/unix/cli.c
@@ -3233,13 +3233,18 @@ vlib_unix_cli_set_prompt (char *prompt)
}
static unix_cli_file_t *
-unix_cli_file_if_interactive (unix_cli_main_t * cm)
+unix_cli_file_if_exists (unix_cli_main_t * cm)
{
- unix_cli_file_t *cf;
if (!cm->cli_file_pool)
return 0;
- cf = pool_elt_at_index (cm->cli_file_pool, cm->current_input_file_index);
- if (!cf->is_interactive)
+ return pool_elt_at_index (cm->cli_file_pool, cm->current_input_file_index);
+}
+
+static unix_cli_file_t *
+unix_cli_file_if_interactive (unix_cli_main_t * cm)
+{
+ unix_cli_file_t *cf;
+ if ((cf = unix_cli_file_if_exists (cm)) && !cf->is_interactive)
return 0;
return cf;
}
@@ -3255,8 +3260,8 @@ unix_cli_quit (vlib_main_t * vm,
unix_cli_main_t *cm = &unix_cli_main;
unix_cli_file_t *cf;
- if (!(cf = unix_cli_file_if_interactive (cm)))
- return clib_error_return (0, "invalid for non-interactive sessions");
+ if (!(cf = unix_cli_file_if_exists (cm)))
+ return clib_error_return (0, "invalid session");
/* Cosmetic: suppress the final prompt from appearing before we die */
cf->is_interactive = 0;
@@ -3546,8 +3551,8 @@ unix_cli_show_terminal (vlib_main_t * vm,
unix_cli_file_t *cf;
vlib_node_t *n;
- if (!(cf = unix_cli_file_if_interactive (cm)))
- return clib_error_return (0, "invalid for non-interactive sessions");
+ if (!(cf = unix_cli_file_if_exists (cm)))
+ return clib_error_return (0, "invalid session");
n = vlib_get_node (vm, cf->process_node_index);