diff options
Diffstat (limited to 'src/vlib/unix/cli.c')
-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 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); |