aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2021-05-10 19:01:42 -0400
committerFlorin Coras <florin.coras@gmail.com>2021-05-11 00:45:33 +0000
commit269e1569e1f7798bf7d7f539daf505b2f1997a08 (patch)
tree0fa4ad620ec8b1159786b11bf9ac7bd8a750dbb3 /src
parent1691da62d9105a134f219adeafd5e27b80725701 (diff)
vlib: exec cmd handle scripts with blank lines
Type: fix Fixes: 2f96e7648b9b7d501088eddff7e4a761973e71f4 Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: Ia75c863850c0df978f61bfc0343a167d8636ed97
Diffstat (limited to 'src')
-rw-r--r--src/vlib/unix/cli.c24
1 files changed, 21 insertions, 3 deletions
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);