]> git.sur5r.net Git - bacula/bacula/commitdiff
Apply patch from bug #1076 by Tullio Andreatta <t.andreatta@troppoavanti.it>
authorKern Sibbald <kern@sibbald.com>
Thu, 1 May 2008 11:50:35 +0000 (11:50 +0000)
committerKern Sibbald <kern@sibbald.com>
Thu, 1 May 2008 11:50:35 +0000 (11:50 +0000)
     that implements multiple commands per line in the console when using
     readline. Modify the default to use a semicolon as the command separator.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6862 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/AUTHORS
bacula/src/console/console.c
bacula/src/version.h
bacula/technotes-2.3

index 1d4b26752c89b09dc8c06634e0f32ba134cf3ef0..605ae87e7e2b1ed9176324b9e632de16fa578262 100644 (file)
@@ -90,5 +90,6 @@ Thomas Glatthor
 Thorsten Enge
 Tim Oberfoell   
 Tomas Cameron
+Tullio Andreatta
 Wolfgang Denk
 Yves Orton
index 67e9baa70739b4d0b51438386b3b76329f1c2fc0..386fac430b8fc811c8e5d34d2b5bb86c38be27a8 100644 (file)
@@ -103,6 +103,9 @@ static int echocmd(FILE *input, BSOCK *UA_sock);
 static int timecmd(FILE *input, BSOCK *UA_sock);
 static int sleepcmd(FILE *input, BSOCK *UA_sock);
 static int execcmd(FILE *input, BSOCK *UA_sock);
+#ifdef HAVE_READLINE
+static int eolcmd(FILE *input, BSOCK *UA_sock);
+#endif
 
 
 #define CONFIG_FILE "bconsole.conf"   /* default configuration file */
@@ -171,6 +174,9 @@ static struct cmdstruct commands[] = {
  { N_("exec"),       execcmd,      _("execute an external command")},
  { N_("exit"),       quitcmd,      _("exit = quit")},
  { N_("zed_keys"),   zed_keyscmd,  _("zed_keys = use zed keys instead of bash keys")},
+#ifdef HAVE_READLINE
+ { N_("separator"),  eolcmd,       _("set command separator")},
+#endif
              };
 #define comsize (sizeof(commands)/sizeof(struct cmdstruct))
 
@@ -340,23 +346,60 @@ static int tls_pem_callback(char *buf, int size, const void *userdata)
 #include "readline.h"
 #include "history.h"
 
+static char eol = ';';
+static int eolcmd(FILE *input, BSOCK *UA_sock)
+{
+   if ((argc > 1) && (strchr("!$%&'()*+,-/:;<>?[]^`{|}~", argk[1][0]) != NULL)) {
+      eol = argk[1][0];
+      return 1;
+   }
+   sendit(_("Missing or illegal separator character.\n"));
+   return 1;
+}
+
 int
 get_cmd(FILE *input, const char *prompt, BSOCK *sock, int sec)
 {
-   char *line;
+   static char *line = NULL;
+   static char *next = NULL;
+   static int do_history = 0;
+   char *command;
 
-   rl_catch_signals = 0;              /* do it ourselves */
-   line = readline((char *)prompt);   /* cast needed for old readlines */
+   if (line == NULL) {
+      do_history = 0;
+      rl_catch_signals = 0;              /* do it ourselves */
+      line = readline((char *)prompt);   /* cast needed for old readlines */
 
-   if (!line) {
-      exit(1);
+      if (!line) {
+         exit(1);
+      }
+      strip_trailing_junk(line);
+      command = line;
+   } else {
+      *next = eol;
+      command = next + 1;
+   }
+
+   next = strchr(command, eol);
+   if (next != NULL) {
+      *next = '\0';
    }
-   strip_trailing_junk(line);
-   sock->msglen = pm_strcpy(&sock->msg, line);
+   if (command != line && isatty(fileno(input))) {
+      senditf("%s%s\n", prompt, command);
+   }
+
+   sock->msglen = pm_strcpy(&sock->msg, command);
    if (sock->msglen) {
-      add_history(sock->msg);
+      do_history++;
+   }
+
+   if (next == NULL) {
+      if (do_history) {
+        add_history(line);
+      }
+      free(line);
+      line = NULL;
    }
-   free(line);
    return 1;
 }
 
index 2aceda5db4cca5eb81f5460b8dc9a86dd1a52997..57bdc43f345165cdcf4747fd23f06ffe715cebeb 100644 (file)
@@ -4,8 +4,8 @@
 
 #undef  VERSION
 #define VERSION "2.3.18"
-#define BDATE   "19 April 2008"
-#define LSMDATE "19Apr08"
+#define BDATE   "01 May 2008"
+#define LSMDATE "01May08"
 
 #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n"
 #define BYEAR "2008"       /* year for copyright messages in progs */
index 24152de4c0c0f59f81cd70796c1730bc19cf7e79..2d695e47801ef0e86fe2fca4c85bcecb5d1f587d 100644 (file)
@@ -24,6 +24,10 @@ Add long term statistics job table
 
 
 General:
+01May08
+kes  Apply patch from bug #1076 by Tullio Andreatta <t.andreatta@troppoavanti.it>
+     that implements multiple commands per line in the console when using 
+     readline. Modify the default to use a semicolon as the command separator.  
 28Apr08
 ebl  Fix SQL query in migration code.
 ebl  Make accurate mode with hash disk pass regression tests