diff options
author | Tomasz Pala <gotar@pld-linux.org> | 2009-06-24 22:23:11 +0100 |
---|---|---|
committer | Paul Jakma <paul@quagga.net> | 2009-06-24 22:26:38 +0100 |
commit | 3f4ab7f9e9ffaee7c448744f45d6e5e2176cce89 (patch) | |
tree | 150f78b31c7b0edae8b5ebfe4f6f8b4176a52dd5 /vtysh | |
parent | 80abd9fe37d8aa5d929686f3d4a717b72bfacb3c (diff) |
[vtysh] Save vtysh history to a file
vtsh_main.c: save 1000 last lines of history to $HOME/.history_quagga (the
file must be created by hand first, this is intended behaviour)
Diffstat (limited to 'vtysh')
-rw-r--r-- | vtysh/vtysh_main.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c index 23ff64f7..4a315a5c 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 history_file[MAXPATHLEN]; /* Flag for indicate executing child command. */ int execute_flag = 0; @@ -188,8 +189,10 @@ vtysh_rl_gets () { using_history(); last = previous_history(); - if (!last || strcmp (last->line, line_read) != 0) + if (!last || strcmp (last->line, line_read) != 0) { add_history (line_read); + append_history(1,history_file); + } } return (line_read); @@ -399,10 +402,13 @@ main (int argc, char **argv, char **env) sigsetjmp (jmpbuf, 1); jmpflag = 1; + snprintf(history_file, sizeof(history_file), "%s/.history_quagga", getenv("HOME")); + read_history(history_file); /* Main command loop. */ while (vtysh_rl_gets ()) vtysh_execute (line_read); + history_truncate_file(history_file,1000); printf ("\n"); /* Rest in peace. */ |