Fix option parsing without --debug after #261

From getopt manual page:

> By default, getopt() permutes the contents of argv as it scans, so that eventually all the nonoptions are at the end. Two other scanning modes are also implemented. [...] If the first character of optstring is '-', then each nonoption argv-element is handled as if it were the argument of an option with character code 1.

> If the first character (following any optional '+' or '-' described above) of optstring is a colon (':'), then getopt() likewise does not print an error message. In addition, it returns ':' instead of '?' to indicate a missing option argument. This allows the caller to distinguish the two different types of errors.
This commit is contained in:
Lily Foster 2023-01-25 11:48:18 -05:00 committed by Simon Ser
parent d5eb85ba1c
commit 2c4bafc57f

2
main.c
View File

@ -1148,7 +1148,7 @@ void log_init(int argc, char **argv) {
optind = 1; optind = 1;
while (1) { while (1) {
int opt_idx = 0; int opt_idx = 0;
c = getopt_long(argc, argv, "d", long_options, &opt_idx); c = getopt_long(argc, argv, "-:d", long_options, &opt_idx);
if (c == -1) { if (c == -1) {
break; break;
} }