]> git.puffer.fish Git - matthieu/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>
Wed, 23 Jan 2019 13:15:52 +0000 (14:15 +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 2a3b74cdb10f538a17109a7d6df695de6cb5b79b..8f998f84d203957a54e721de4bc82148d774d6f3 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);
 }
 
@@ -2858,7 +2858,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;
 }
 
@@ -2878,7 +2878,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;
        }
 
@@ -2887,7 +2887,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;
@@ -3445,6 +3445,7 @@ void vtysh_init_vty(void)
 
        /* set default output */
        vty->of = stdout;
+       vtysh_pager_envdef(false);
 
        /* Initialize commands. */
        cmd_init(0);
@@ -3773,6 +3774,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);