From 38af20569ca45dacb858697614bd93d05e2e2b12 Mon Sep 17 00:00:00 2001 From: ekorh475 Date: Mon, 12 Dec 2016 14:08:22 +0200 Subject: [PATCH] MaxAdmin defaults to Emacs-mode and other small changes 1. MaxAdmin now defaults to Emacs-mode. To activate Vim-mode, give the option 'i' when starting. 2. "history" and "source"-commands are parsed correctly. 3. Added a check to DoSource() so that empty commands are not sent. MaxScale doesn't respond to empty commands which would cause MaxAdmin to wait forever. --- client/maxadmin.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/client/maxadmin.c b/client/maxadmin.c index 6deaf1ee7..0bcfb6737 100644 --- a/client/maxadmin.c +++ b/client/maxadmin.c @@ -101,6 +101,7 @@ static struct option long_options[] = {"version", no_argument, 0, 'v'}, {"help", no_argument, 0, '?'}, {"emacs", no_argument, 0, 'e'}, + {"vim", no_argument, 0, 'i'}, {0, 0, 0, 0} }; @@ -132,7 +133,7 @@ main(int argc, char **argv) char *user = NULL; char *passwd = NULL; char *socket_path = NULL; - int use_emacs = 0; + int use_emacs = 1; read_inifile(&socket_path, &hostname, &port, &user, &passwd, &use_emacs); @@ -141,7 +142,7 @@ main(int argc, char **argv) int option_index = 0; char c; - while ((c = getopt_long(argc, argv, "h:p::P:u:S:v?e", + while ((c = getopt_long(argc, argv, "h:p::P:u:S:v?ei", long_options, &option_index)) >= 0) { switch (c) @@ -184,6 +185,10 @@ main(int argc, char **argv) use_emacs = 1; break; + case 'i': + use_emacs = 0; + break; + case '?': DoUsage(argv[0]); exit(optopt ? EXIT_FAILURE : EXIT_SUCCESS); @@ -358,7 +363,6 @@ main(int argc, char **argv) } #ifdef HISTORY - el_line(el); history(hist, &ev, H_ENTER, buf); #endif @@ -767,7 +771,7 @@ DoSource(int so, char *file) pe--; } - if (*ptr != '#') /* Comment */ + if (*ptr != '#' && *ptr != '\0') /* Comment or empty */ { if (!sendCommand(so, ptr)) {