]> git.puffer.fish Git - mirror/frr.git/commitdiff
vtysh: fix pager compatibility handling
authorDavid Lamparter <equinox@diac24.net>
Wed, 23 Jan 2019 13:15:52 +0000 (14:15 +0100)
committerDavid Lamparter <equinox@diac24.net>
Tue, 19 Feb 2019 13:06:01 +0000 (14:06 +0100)
I just straight up forgot checking VTYSH_PAGER at startup, and the
"terminal paginate" command is only installed to VIEW_NODE so it can't
be processed from vtysh.conf in CONFIG_NODE...

Signed-off-by: David Lamparter <equinox@diac24.net>
vtysh/vtysh.c

index 41fd6ed7d68affd77e60c2e81735581a0bf2c379..9ff869e5033b93a8efe32a7d6c8f7a6acbd6bbd8 100644 (file)
@@ -104,7 +104,7 @@ static int vty_close_pager(struct vty *vty)
        return 0;
 }
 
-static void vtysh_pager_envdef(void)
+static void vtysh_pager_envdef(bool fallback)
 {
        char *pager_defined;
 
@@ -112,7 +112,7 @@ static void vtysh_pager_envdef(void)
 
        if (pager_defined)
                vtysh_pager_name = strdup(pager_defined);
-       else
+       else if (fallback)
                vtysh_pager_name = strdup(VTYSH_PAGER);
 }
 
@@ -2893,7 +2893,7 @@ DEFUN (vtysh_terminal_paginate,
        vtysh_pager_name = NULL;
 
        if (strcmp(argv[0]->text, "no"))
-               vtysh_pager_envdef();
+               vtysh_pager_envdef(true);
        return CMD_SUCCESS;
 }
 
@@ -2913,7 +2913,7 @@ DEFUN (vtysh_terminal_length,
 
        if (!strcmp(argv[0]->text, "no") || !strcmp(argv[1]->text, "no")) {
                /* "terminal no length" = use VTYSH_PAGER */
-               vtysh_pager_envdef();
+               vtysh_pager_envdef(true);
                return CMD_SUCCESS;
        }
 
@@ -2922,7 +2922,7 @@ DEFUN (vtysh_terminal_length,
                vty_out(vty,
                        "%% The \"terminal length\" command is deprecated and its value is ignored.\n"
                        "%% Please use \"terminal paginate\" instead with OS TTY length handling.\n");
-               vtysh_pager_envdef();
+               vtysh_pager_envdef(true);
        }
 
        return CMD_SUCCESS;
@@ -3479,6 +3479,7 @@ void vtysh_init_vty(void)
 
        /* set default output */
        vty->of = stdout;
+       vtysh_pager_envdef(false);
 
        /* Initialize commands. */
        cmd_init(0);
@@ -3812,6 +3813,7 @@ void vtysh_init_vty(void)
        /* "write memory" command. */
        install_element(ENABLE_NODE, &vtysh_write_memory_cmd);
 
+       install_element(CONFIG_NODE, &vtysh_terminal_paginate_cmd);
        install_element(VIEW_NODE, &vtysh_terminal_paginate_cmd);
        install_element(VIEW_NODE, &vtysh_terminal_length_cmd);
        install_element(VIEW_NODE, &vtysh_terminal_no_length_cmd);