diff options
author | Benoît Ganne <bganne@cisco.com> | 2020-05-15 16:12:23 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2020-05-15 23:35:06 +0000 |
commit | 10a22a629468b18f5b07316980e2761285283939 (patch) | |
tree | 73e795445aee24010eeb6e99aebdfd7ce913f622 | |
parent | 3ca663e743dda703e76d8493a0c5cf13d7004c63 (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>
-rw-r--r-- | src/vlib/unix/cli.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/vlib/unix/cli.c b/src/vlib/unix/cli.c index c7249eb2af4..b553e12bac2 100644 --- a/src/vlib/unix/cli.c +++ b/src/vlib/unix/cli.c @@ -3238,13 +3238,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; } @@ -3260,8 +3265,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; @@ -3551,8 +3556,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); |