vtysh: Add error code if daemon is not running

After `<daemon_name> is not running` message vtysh does not return
error. For example if you disable ospf in `/etc/frr/daemons` and run
`vtysh -c configure -c "router ospf"` it prints the message to stderr,
but returns 0.

This commit will make vtysh return error when not in interractive mode.

But if you run commands from vtysh, you will still be able to enter
views and exit them if daemon is not running.

Signed-off-by: Yaroslav Fedoriachenko <yar.fed99@gmail.com>
This commit is contained in:
Yaroslav Fedoriachenko 2021-08-17 18:30:03 +03:00
parent f0a4777192
commit a32f6a107f
2 changed files with 4 additions and 2 deletions

View File

@ -229,6 +229,7 @@ struct cmd_node {
#define CMD_WARNING_CONFIG_FAILED 13
#define CMD_NOT_MY_INSTANCE 14
#define CMD_NO_LEVEL_UP 15
#define CMD_ERR_NO_DAEMON 16
/* Argc max counts. */
#define CMD_ARGC_MAX 256

View File

@ -602,7 +602,8 @@ static int vtysh_execute_func(const char *line, int pager)
fprintf(stderr,
"%s is not running\n",
vtysh_client[i].name);
continue;
cmd_stat = CMD_ERR_NO_DAEMON;
break;
}
}
cmd_stat = vtysh_client_execute(
@ -611,7 +612,7 @@ static int vtysh_execute_func(const char *line, int pager)
break;
}
}
if (cmd_stat != CMD_SUCCESS)
if (cmd_stat != CMD_SUCCESS && cmd_stat != CMD_ERR_NO_DAEMON)
break;
if (cmd->func)