summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/input.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/client/input.c b/client/input.c
index 20ce7f9c..6d9edf2d 100644
--- a/client/input.c
+++ b/client/input.c
@@ -88,26 +88,38 @@ void __connmanctl_redraw_rl(void)
static void rl_handler(char *input)
{
- char **args;
- int num, err;
+ char **args, **trim_args;
+ int num, len, err, i;
if (input == NULL) {
rl_newline(1, '\n');
g_main_loop_quit(main_loop);
return;
}
- if (*input != '\0')
- add_history(input);
args = g_strsplit(input, " ", 0);
num = g_strv_length(args);
- err = __connmanctl_commands(connection, args, num);
+ trim_args = g_new0(char *, num);
+ for (i = 0, len = 0; i < num; i++) {
+ if (*args[i] != '\0') {
+ trim_args[len] = args[i];
+ len++;
+ }
+ }
- g_strfreev(args);
+ if (len > 0) {
- if (err > 0)
- g_main_loop_quit(main_loop);
+ add_history(input);
+
+ err = __connmanctl_commands(connection, trim_args, len);
+
+ if (err > 0)
+ g_main_loop_quit(main_loop);
+ }
+
+ g_strfreev(args);
+ g_free(trim_args);
}
static gboolean input_handler(GIOChannel *channel, GIOCondition condition,