diff --git a/tools/obexctl.c b/tools/obexctl.c
index 512a145..b4fdc1c 100644
--- a/tools/obexctl.c
+++ b/tools/obexctl.c
#include <signal.h>
#include <sys/signalfd.h>
#include <inttypes.h>
+#include <wordexp.h>
#include <readline/readline.h>
#include <readline/history.h>
static void rl_handler(char *input)
{
+ wordexp_t w;
int argc;
- char **argv = NULL;
+ char **argv;
int i;
if (!input) {
if (!strlen(input))
goto done;
- g_strstrip(input);
add_history(input);
- argv = g_strsplit(input, " ", -1);
- if (argv == NULL)
+ if (wordexp(input, &w, WRDE_NOCMD))
goto done;
- for (argc = 0; argv[argc];)
- argc++;
+ if (w.we_wordc == 0)
+ goto free_we;
- if (argc == 0)
- goto done;
+ argv = w.we_wordv;
+ argc = w.we_wordc;
for (i = 0; cmd_table[i].cmd; i++) {
if (strcmp(argv[0], cmd_table[i].cmd))
if (cmd_table[i].func) {
cmd_table[i].func(argc, argv);
- goto done;
+ goto free_we;
}
}
if (strcmp(argv[0], "help")) {
printf("Invalid command\n");
- goto done;
+ goto free_we;
}
printf("Available commands:\n");
cmd_table[i].desc ? : "");
}
+free_we:
+ wordfree(&w);
done:
- g_strfreev(argv);
free(input);
}