Bugfix for -q and -p flags

This commit is contained in:
Bruce Hill 2024-04-12 14:18:03 -04:00
parent 37a0ca997d
commit 60cc8f5b3d

15
ask.c
View File

@ -188,7 +188,7 @@ static char *get_input(FILE *in, FILE *out, const char *prompt, const char *init
}
int start = 0, backtrack = 0;
while (1) {
for (;;) {
case_sensitive = 0;
for (const char *p = buf; *p; ++p)
case_sensitive |= ('A' <= *p && *p <= 'Z');
@ -391,12 +391,17 @@ int main(int argc, char *argv[])
case '0': delim = '\0'; break;
case 'y': yes = 1; quickpick = 1; break;
case 'n': no = 1; quickpick = 1; break;
case 'p':
if (a + 1 >= argc) goto help_flag;
prompt = argv[++a];
break;
case 'q':
if (a + 1 >= argc) goto help_flag;
query = argv[++a];
break;
default: goto help_flag;
}
}
} else if (strcmp(argv[a], "-p") == 0) {
prompt = argv[++a];
} else if (strcmp(argv[a], "-q") == 0) {
query = argv[++a];
} else if (strncmp(argv[a], "--read0", strlen("--read0")) == 0) {
delim = '\0';
} else if (strncmp(argv[a], "--prompt=", strlen("--prompt=")) == 0) {