diff options
| author | pogojotz <pogojotz@gmx.net> | 2017-11-06 22:43:32 +0100 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-11-12 13:09:29 -0500 |
| commit | f806f29c4953b2b14c5d3c474e4dbdb54a9732dd (patch) | |
| tree | d38b7a12f934f0f3d9ecba5aa57e64d440fd3847 /lib/command.c | |
| parent | 1757d7169394efd65f878e86510e02d57dd5c9ca (diff) | |
lib: Fix command `copy running-config startup-config` to alias `write file`
Fixes: #1412
Signed-off-by: Juergen Werner <pogojotz@gmx.net>
Diffstat (limited to 'lib/command.c')
| -rw-r--r-- | lib/command.c | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/lib/command.c b/lib/command.c index 2e91d84bf3..9992e81ef5 100644 --- a/lib/command.c +++ b/lib/command.c @@ -1556,11 +1556,14 @@ DEFUN (show_commandtree, return cmd_list_cmds(vty, argc == 3); } -static void vty_write_config(struct vty *vty) +static int vty_write_config(struct vty *vty) { size_t i; struct cmd_node *node; + if (host.noconfig) + return CMD_SUCCESS; + if (vty->type == VTY_TERM) { vty_out(vty, "\nCurrent configuration:\n"); vty_out(vty, "!\n"); @@ -1580,19 +1583,12 @@ static void vty_write_config(struct vty *vty) if (vty->type == VTY_TERM) { vty_out(vty, "end\n"); } -} -/* Write current configuration into file. */ + return CMD_SUCCESS; +} -DEFUN (config_write, - config_write_cmd, - "write [<file|memory|terminal>]", - "Write running configuration to memory, network, or terminal\n" - "Write to configuration file\n" - "Write configuration currently in memory\n" - "Write configuration to terminal\n") +static int file_write_config(struct vty *vty) { - int idx_type = 1; int fd, dirfd; char *config_file, *slash; char *config_file_tmp = NULL; @@ -1601,13 +1597,6 @@ DEFUN (config_write, struct vty *file_vty; struct stat conf_stat; - // if command was 'write terminal' or 'show running-config' - if (argc == 2 && (strmatch(argv[idx_type]->text, "terminal") - || strmatch(argv[0]->text, "show"))) { - vty_write_config(vty); - return CMD_SUCCESS; - } - if (host.noconfig) return CMD_SUCCESS; @@ -1706,14 +1695,34 @@ finished: return ret; } +/* Write current configuration into file. */ + +DEFUN (config_write, + config_write_cmd, + "write [<file|memory|terminal>]", + "Write running configuration to memory, network, or terminal\n" + "Write to configuration file\n" + "Write configuration currently in memory\n" + "Write configuration to terminal\n") +{ + const int idx_type = 1; + + // if command was 'write terminal' or 'write memory' + if (argc == 2 && (!strcmp(argv[idx_type]->text, "terminal"))) { + return vty_write_config(vty); + } + + return file_write_config(vty); +} + /* ALIAS_FIXME for 'write <terminal|memory>' */ DEFUN (show_running_config, show_running_config_cmd, "show running-config", SHOW_STR - "running configuration (same as write terminal/memory)\n") + "running configuration (same as write terminal)\n") { - return config_write(self, vty, argc, argv); + return vty_write_config(vty); } /* ALIAS_FIXME for 'write file' */ @@ -1722,11 +1731,9 @@ DEFUN (copy_runningconf_startupconf, "copy running-config startup-config", "Copy configuration\n" "Copy running config to... \n" - "Copy running config to startup config (same as write file)\n") + "Copy running config to startup config (same as write file/memory)\n") { - if (!host.noconfig) - vty_write_config(vty); - return CMD_SUCCESS; + return file_write_config(vty); } /** -- **/ |
