summaryrefslogtreecommitdiff
path: root/vtysh/vtysh.c
diff options
context:
space:
mode:
authorpaul <paul>2003-05-01 14:29:48 +0000
committerpaul <paul>2003-05-01 14:29:48 +0000
commita805cc2d7030694ae2ae38403452ac3b90a40cff (patch)
tree74a32b6e767657d88239a30d26c5a9fcbb64dd37 /vtysh/vtysh.c
parent6cbbc3cc9fc3127c6ad45e73755b4f0c3afff31a (diff)
From: Sergiy Vyshnevetskiy <serg@vostok.net>
Subject: [zebra 18941] Re: [PATCH] misc patch Program shouldn't terminate on pager execution failure. We can also use "PAGER" environment variable - it's very common.
Diffstat (limited to 'vtysh/vtysh.c')
-rw-r--r--vtysh/vtysh.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index a3b21c7b..d1a5c5fd 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -350,6 +350,8 @@ vtysh_pager_init ()
{
vtysh_pager_name = getenv ("VTYSH_PAGER");
if (! vtysh_pager_name)
+ vtysh_pager_name = getenv ("PAGER");
+ if (! vtysh_pager_name)
vtysh_pager_name = "more";
}
@@ -361,6 +363,7 @@ vtysh_execute_func (char *line, int pager)
vector vline;
struct cmd_element *cmd;
FILE *fp = NULL;
+ int closepager=0;
/* Split readline string up into the vector */
vline = cmd_make_strvec (line);
@@ -394,9 +397,11 @@ vtysh_execute_func (char *line, int pager)
fp = popen (vtysh_pager_name, "w");
if (fp == NULL)
{
- perror ("popen");
- exit (1);
+ perror ("popen failed for pager");
+ fp = stdout;
}
+ else
+ closepager=1;
}
else
fp = stdout;
@@ -425,12 +430,11 @@ vtysh_execute_func (char *line, int pager)
if (vline == NULL)
{
- if (pager && vtysh_pager_name && fp)
+ if (pager && vtysh_pager_name && fp && closepager)
{
if (pclose (fp) == -1)
{
- perror ("pclose");
- exit (1);
+ perror ("pclose failed for pager");
}
fp = NULL;
}
@@ -478,12 +482,11 @@ vtysh_execute_func (char *line, int pager)
(*cmd->func) (cmd, vty, 0, NULL);
}
}
- if (pager && vtysh_pager_name && fp)
+ if (pager && vtysh_pager_name && fp && closepager)
{
if (pclose (fp) == -1)
{
- perror ("pclose");
- exit (1);
+ perror ("pclose failed for pager");
}
fp = NULL;
}