diff options
| author | David Lamparter <equinox@diac24.net> | 2018-10-19 12:11:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-19 12:11:21 +0200 |
| commit | e79ab0ca33999fc818de5453f49b4918940e02ca (patch) | |
| tree | 52f272a4aa304166c189e415019f362cbc274cf9 /lib/command.c | |
| parent | e2f68d82e9e5fe2b060ded949dd9780e33264ffe (diff) | |
| parent | 7ab57d19ce694b4fb2b15e98647571ea230e422f (diff) | |
Merge pull request #3163 from donaldsharp/more_vty_errors
lib, vtysh: Allow notification across multiple lines of failure
Diffstat (limited to 'lib/command.c')
| -rw-r--r-- | lib/command.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/command.c b/lib/command.c index 60c5f4e75b..6fe4ae2d8f 100644 --- a/lib/command.c +++ b/lib/command.c @@ -1281,7 +1281,8 @@ int cmd_execute(struct vty *vty, const char *cmd, * as to why no command could be executed. */ int command_config_read_one_line(struct vty *vty, - const struct cmd_element **cmd, int use_daemon) + const struct cmd_element **cmd, + uint32_t line_num, int use_daemon) { vector vline; int saved_node; @@ -1322,8 +1323,16 @@ int command_config_read_one_line(struct vty *vty, } } - if (ret != CMD_SUCCESS && ret != CMD_WARNING) - memcpy(vty->error_buf, vty->buf, VTY_BUFSIZ); + if (ret != CMD_SUCCESS && ret != CMD_WARNING) { + struct vty_error *ve = XCALLOC(MTYPE_TMP, sizeof(*ve)); + + memcpy(ve->error_buf, vty->buf, VTY_BUFSIZ); + ve->line_num = line_num; + if (!vty->error) + vty->error = list_new(); + + listnode_add(vty->error, ve); + } cmd_free_strvec(vline); @@ -1337,10 +1346,9 @@ int config_from_file(struct vty *vty, FILE *fp, unsigned int *line_num) *line_num = 0; while (fgets(vty->buf, VTY_BUFSIZ, fp)) { - if (!error_ret) - ++(*line_num); + ++(*line_num); - ret = command_config_read_one_line(vty, NULL, 0); + ret = command_config_read_one_line(vty, NULL, *line_num, 0); if (ret != CMD_SUCCESS && ret != CMD_WARNING && ret != CMD_ERR_NOTHING_TODO) |
