summaryrefslogtreecommitdiff
path: root/vtysh
diff options
context:
space:
mode:
Diffstat (limited to 'vtysh')
-rw-r--r--vtysh/vtysh_main.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c
index 55a430d5..23ff64f7 100644
--- a/vtysh/vtysh_main.c
+++ b/vtysh/vtysh_main.c
@@ -162,6 +162,7 @@ struct option longopts[] =
{ "echo", no_argument, NULL, 'E'},
{ "dryrun", no_argument, NULL, 'C'},
{ "help", no_argument, NULL, 'h'},
+ { "noerror", no_argument, NULL, 'n'},
{ 0 }
};
@@ -221,6 +222,7 @@ main (int argc, char **argv, char **env)
} *cmd = NULL;
struct cmd_rec *tail = NULL;
int echo_command = 0;
+ int no_error = 0;
/* Preserve name of myself. */
progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
@@ -232,7 +234,7 @@ main (int argc, char **argv, char **env)
/* Option handling. */
while (1)
{
- opt = getopt_long (argc, argv, "be:c:d:EhC", longopts, 0);
+ opt = getopt_long (argc, argv, "be:c:d:nEhC", longopts, 0);
if (opt == EOF)
break;
@@ -261,6 +263,9 @@ main (int argc, char **argv, char **env)
case 'd':
daemon_name = optarg;
break;
+ case 'n':
+ no_error = 1;
+ break;
case 'E':
echo_command = 1;
break;
@@ -300,6 +305,10 @@ main (int argc, char **argv, char **env)
if(dryrun)
return(0);
+ /* Ignore error messages */
+ if (no_error)
+ freopen("/dev/null", "w", stdout);
+
/* Make sure we pass authentication before proceeding. */
vtysh_auth ();
@@ -332,9 +341,10 @@ main (int argc, char **argv, char **env)
log_it(cmd->line);
ret = vtysh_execute_no_pager(cmd->line);
- if (ret != CMD_SUCCESS
- && ret != CMD_SUCCESS_DAEMON
- && ret != CMD_WARNING)
+ if (!no_error &&
+ ! (ret == CMD_SUCCESS ||
+ ret == CMD_SUCCESS_DAEMON ||
+ ret == CMD_WARNING))
exit(1);
cmd->line = eol+1;
@@ -347,9 +357,10 @@ main (int argc, char **argv, char **env)
log_it(cmd->line);
ret = vtysh_execute_no_pager(cmd->line);
- if (ret != CMD_SUCCESS
- && ret != CMD_SUCCESS_DAEMON
- && ret != CMD_WARNING)
+ if (!no_error &&
+ ! (ret == CMD_SUCCESS ||
+ ret == CMD_SUCCESS_DAEMON ||
+ ret == CMD_WARNING))
exit(1);
{