{"record":{"id":"aa8dd8e100d7942b","repo":"NationalSecurityAgency/ghidra","slug":"s-invalid-option-c-n","errorCode":null,"errorMessage":"%s: invalid option -- %c\\n","messagePattern":"(.+?): invalid option -- %c\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"GPL/DemanglerGnu/src/demangler_gnu_v2_41/c/getopt.c","lineNumber":796,"sourceCode":"\n  {\n    char c = *nextchar++;\n    char *temp = my_index (optstring, c);\n\n    /* Increment `optind' when we start to process its last character.  */\n    if (*nextchar == '\\0')\n      ++optind;\n\n    if (temp == NULL || c == ':')\n      {\n\tif (opterr)\n\t  {\n\t    if (posixly_correct)\n\t      /* 1003.2 specifies the format of this message.  */\n\t      fprintf (stderr, _(\"%s: illegal option -- %c\\n\"),\n\t\t       argv[0], c);\n\t    else\n\t      fprintf (stderr, _(\"%s: invalid option -- %c\\n\"),\n\t\t       argv[0], c);\n\t  }\n\toptopt = c;\n\treturn '?';\n      }\n    /* Convenience. Treat POSIX -W foo same as long option --foo */\n    if (temp[0] == 'W' && temp[1] == ';')\n      {\n\tchar *nameend;\n\tconst struct option *p;\n\tconst struct option *pfound = NULL;\n\tint exact = 0;\n\tint ambig = 0;\n\tint indfound = 0;\n\tint option_index;\n\n\t/* This is an option that requires an argument.  */\n\tif (*nextchar != '\\0')","sourceCodeStart":778,"sourceCodeEnd":814,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/GPL/DemanglerGnu/src/demangler_gnu_v2_41/c/getopt.c#L778-L814","documentation":"GNU getopt's non-POSIX diagnostic for an invalid short option. Printed when posixly_correct is false and a short-option character is absent from optstring or equals ':'. Identical control flow to the POSIX variant: optopt is set and '?' is returned.","triggerScenarios":"A short option not in optstring is passed while POSIX mode is off; the ':' character is used as an option letter.","commonSituations":"Default (non-POSIX) builds; optstring drift relative to help text; a typo'd flag on the command line.","solutions":["Add the missing option letter to optstring.","Enable POSIXLY_CORRECT if you want the 1003.2 wording (does not fix the underlying invalid option).","Set opterr = 0 and handle '?' / optopt manually.","Validate argv before calling getopt for early, custom error reporting."],"exampleFix":"// before\nwhile ((c = getopt(argc, argv, \"ab:c\")) != -1) { ... }  // user: prog -z\n\n// after\nwhile ((c = getopt(argc, argv, \"ab:cz\")) != -1) { ... }","handlingStrategy":"validation","validationCode":"opterr = 0;\nwhile ((c = getopt(argc, argv, \"ab:c\")) != -1) {\n  if (c == '?') { fprintf(stderr, \"unknown option -%c\\n\", optopt); exit(2); }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat optstring as the single source of truth for accepted flags.","Pre-validate argv against optstring for clearer messages.","Set opterr=0 in programs that localize or customize messages."],"tags":["cli","getopt","argument-parsing","c"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}