diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2016-03-09 13:25:02 +0100 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2016-03-09 13:25:02 +0100 |
commit | 3221dca81ea45765bb8707fa81cf8f1c6da36f71 (patch) | |
tree | dc1a3cf572c4dc05990d99ef67b7d78880760c20 /vtysh/vtysh_main.c | |
parent | Merge branch 'cmaster' of ssh://stash.cumulusnetworks.com:7999/quag/quagga in... (diff) | |
download | frr-3221dca81ea45765bb8707fa81cf8f1c6da36f71.tar.xz frr-3221dca81ea45765bb8707fa81cf8f1c6da36f71.zip |
vtysh: Set an erroneous exit code if dry run fails because of syntax error
vtysh has a -C option to do a dry run of the quagga commands. However, the
program always returns 0 even when there's an error detected in the command.
Furthermore, it only parses vtysh.conf, not Quagga.conf.
This patch makes vtysh -C parse Quagga.conf also and return a non-zero
exit code so that network automation tools can catch this to flag errors in
syntax. This non-zero exit code along with printing the exact error with the
line number and offending line itself should help in fixing the error. But
this lack of proper error code requires the automation tools to go through
an additional hoop to validate the syntax.
Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
Diffstat (limited to 'vtysh/vtysh_main.c')
-rw-r--r-- | vtysh/vtysh_main.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c index befc86e6e..d8b769ba2 100644 --- a/vtysh/vtysh_main.c +++ b/vtysh/vtysh_main.c @@ -42,6 +42,7 @@ char *progname; /* Configuration file name and directory. */ char config_default[] = SYSCONFDIR VTYSH_DEFAULT_CONFIG; +char quagga_config_default[] = SYSCONFDIR QUAGGA_DEFAULT_CONFIG; char history_file[MAXPATHLEN]; /* Flag for indicate executing child command. */ @@ -232,6 +233,7 @@ main (int argc, char **argv, char **env) int echo_command = 0; int no_error = 0; int markfile = 0; + int ret = 0; char *homedir = NULL; /* Preserve name of myself. */ @@ -330,9 +332,13 @@ main (int argc, char **argv, char **env) { if (inputfile) { - vtysh_read_config(inputfile); + ret = vtysh_read_config(inputfile); } - return(0); + else + { + ret = vtysh_read_config(quagga_config_default); + } + exit(ret); } /* Ignore error messages */ @@ -357,8 +363,8 @@ main (int argc, char **argv, char **env) if (inputfile) { - vtysh_read_config(inputfile); - exit(0); + ret = vtysh_read_config(inputfile); + exit(ret); } /* |