diff --git a/client/main.c b/client/main.c index d02df6e7e..40bee16f3 100644 --- a/client/main.c +++ b/client/main.c @@ -428,11 +428,15 @@ static void rl_handler(char *input) add_history(input); - cmd = strtok(input, " "); + cmd = strtok_r(input, " ", &arg); if (!cmd) return; - arg = strtok(NULL, " "); + if (arg) { + int len = strlen(arg); + if (len > 0 && arg[len - 1] == ' ') + arg[len - 1] = '\0'; + } for (i = 0; cmd_table[i].cmd; i++) { if (strcmp(cmd, cmd_table[i].cmd))