Browse Source

Vtysh fixes:
* replace -e with -c
* don't save command in history if last line is the same one
* doc/help fixes

hasso 17 years ago
parent
commit
4991f6ca30
3 changed files with 24 additions and 7 deletions
  1. 1 1
      doc/vtysh.1
  2. 7 0
      vtysh/ChangeLog
  3. 16 6
      vtysh/vtysh_main.c

+ 1 - 1
doc/vtysh.1

@@ -19,7 +19,7 @@ routing engine.
 .SH OPTIONS
 
 .TP
-\fB\-e
+\fB\-c
 Specify command to be executed under batch mode.
 
 

+ 7 - 0
vtysh/ChangeLog

@@ -1,3 +1,10 @@
+2004-04-06 Hasso Tepper <hasso@estpak.ee>
+
+	* vtysh_main.c: Don't save command to history if last command already
+	  there is same.
+	* vtysh_main.c: Replace -e with -c.
+	* vtysh_main.c: Fix help.
+
 2004-03-04 Hasso Tepper <hasso@estpak.ee>
 
 	* vtysh.c: Remove using PAGER.

+ 16 - 6
vtysh/vtysh_main.c

@@ -144,10 +144,9 @@ usage (int status)
   else
     {    
       printf ("Usage : %s [OPTION...]\n\n\
-Daemon which manages kernel routing table management and \
-redistribution between different routing protocols.\n\n\
+Integrated shell for Quagga routing software suite. \n\n\
 -b, --boot               Execute boot startup configuration\n\
--e, --eval               Execute argument as command\n\
+-c, --command            Execute argument as command\n\
 -h, --help               Display this help and exit\n\
 \n\
 Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS);
@@ -159,7 +158,9 @@ Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS);
 struct option longopts[] = 
 {
   { "boot",                no_argument,             NULL, 'b'},
+  /* For compatibility with older zebra/quagga versions */
   { "eval",                 required_argument,       NULL, 'e'},
+  { "command",              required_argument,       NULL, 'c'},
   { "help",                 no_argument,             NULL, 'h'},
   { 0 }
 };
@@ -168,6 +169,7 @@ struct option longopts[] =
 char *
 vtysh_rl_gets ()
 {
+  HIST_ENTRY *last;
   /* If the buffer has already been allocated, return the memory
      to the free pool. */
   if (line_read)
@@ -179,9 +181,16 @@ vtysh_rl_gets ()
   /* Get a line from the user.  Change prompt according to node.  XXX. */
   line_read = readline (vtysh_prompt ());
      
-  /* If the line has any text in it, save it on the history. */
+  /* If the line has any text in it, save it on the history. But only if
+   * last command in history isn't the same one.
+   */
   if (line_read && *line_read)
-    add_history (line_read);
+    {
+      using_history();
+      last = previous_history();
+      if (!last || strcmp (last->line, line_read) != 0)
+	add_history (line_read);
+    }
      
   return (line_read);
 }
@@ -203,7 +212,7 @@ main (int argc, char **argv, char **env)
   /* Option handling. */
   while (1) 
     {
-      opt = getopt_long (argc, argv, "be:h", longopts, 0);
+      opt = getopt_long (argc, argv, "be:c:h", longopts, 0);
     
       if (opt == EOF)
 	break;
@@ -216,6 +225,7 @@ main (int argc, char **argv, char **env)
 	  boot_flag = 1;
 	  break;
 	case 'e':
+	case 'c':
 	  eval_flag = 1;
 	  eval_line = optarg;
 	  break;