diff options
| author | Lily Foster <lily@lily.flowers> | 2023-01-25 11:48:18 -0500 |
|---|---|---|
| committer | Simon Ser <contact@emersion.fr> | 2023-01-26 16:34:49 +0100 |
| commit | 2c4bafc57f278fbd2a564c357da410173be28bc6 (patch) | |
| tree | c8b86808107ac7e8c2e9fe63767fc938fd53bfe9 | |
| parent | d5eb85ba1c0231a8a069215ae3c23d070072f53a (diff) | |
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.
| -rw-r--r-- | main.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -1148,7 +1148,7 @@ void log_init(int argc, char **argv) { optind = 1; while (1) { 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) { break; } |
