From 269e1569e1f7798bf7d7f539daf505b2f1997a08 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Mon, 10 May 2021 19:01:42 -0400 Subject: vlib: exec cmd handle scripts with blank lines Type: fix Fixes: 2f96e7648b9b7d501088eddff7e4a761973e71f4 Signed-off-by: Dave Barach Change-Id: Ia75c863850c0df978f61bfc0343a167d8636ed97 --- src/vlib/unix/cli.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src/vlib/unix/cli.c') diff --git a/src/vlib/unix/cli.c b/src/vlib/unix/cli.c index 7b9a2315910..c8ebb3313b8 100644 --- a/src/vlib/unix/cli.c +++ b/src/vlib/unix/cli.c @@ -3436,10 +3436,28 @@ unix_cli_exec (vlib_main_t * vm, vec_free (expanded); } - while (unformat_user (&sub_input, unformat_line_input, line_input)) + while (1) { - vlib_cli_input (vm, line_input, 0, 0); - unformat_free (line_input); + int rv = unformat_user (&sub_input, unformat_line_input, line_input); + + /* No match? */ + if (rv == 0) + { + /* Out of input, we're done... */ + if (sub_input.index == UNFORMAT_END_OF_INPUT) + { + unformat_free (line_input); + break; + } + /* Blank line... */ + sub_input.index++; + } + else + { + /* Process the line we just read */ + vlib_cli_input (vm, line_input, 0, 0); + unformat_free (line_input); + } } unformat_free (&sub_input); -- cgit 1.2.3-korg