Skip to content

Commit 49f77be

Browse files
committed
empty input passed as is
1 parent 25d8402 commit 49f77be

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

main.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,8 @@ static char *get_input(const char *prompt)
211211
printf("\n%s", prompt); fflush(stdout);
212212
input[0] = 0;
213213
p = fgets(input, sizeof(input), stdin);
214-
if (p && *p) {
214+
if (p)
215215
p[strcspn(p, "\n\r")] = 0;
216-
}
217216
if (opt_echo && p)
218217
printf("%s\n", p);
219218
return p;
@@ -406,6 +405,8 @@ int main(int argc, const char **argv)
406405
char *p;
407406
int cmd_mode = 0;
408407
p = get_input("> ");
408+
if (p && *p != '/')
409+
p = trim(p);
409410
if (!p || !strcmp(p, "/quit")) {
410411
printf("\n");
411412
break;
@@ -439,7 +440,11 @@ int main(int argc, const char **argv)
439440
}
440441
if (rc) { /* try act */
441442
free(str);
442-
snprintf(cmd, sizeof(cmd), "act %s", p);
443+
if (!*p) /* empty? */
444+
cmd[0] = 0;
445+
else
446+
snprintf(cmd, sizeof(cmd), "act %s", p);
447+
443448
str = instead_cmd(cmd, &rc);
444449
}
445450
if (str) {

0 commit comments

Comments
 (0)