{"record":{"id":"fc86928ccb3fe985","repo":"NationalSecurityAgency/ghidra","slug":"s-option-c-s-doesn-t-allow-an-argument","errorCode":null,"errorMessage":"%s: option `%c%s' doesn't allow an argument","messagePattern":"(.+?): option `%c(.+?)' doesn't allow an argument","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"GPL/DemanglerGnu/src/demangler_gnu_v2_24/c/getopt.c","lineNumber":716,"sourceCode":"\t  optind++;\n\t  if (*nameend)\n\t    {\n\t      /* Don't test has_arg with >, because some C compilers don't\n\t\t allow it to be used on enums.  */\n\t      if (pfound->has_arg)\n\t\toptarg = nameend + 1;\n\t      else\n\t\t{\n\t\t  if (opterr)\n\t\t    {\n\t\t      if (argv[optind - 1][1] == '-')\n\t\t\t/* --option */\n\t\t\tfprintf (stderr,\n\t\t\t\t _(\"%s: option `--%s' doesn't allow an argument\\n\"),\n\t\t\t\t argv[0], pfound->name);\n\t\t      else\n\t\t\t/* +option or -option */\n\t\t\tfprintf (stderr,\n\t\t\t\t _(\"%s: option `%c%s' doesn't allow an argument\\n\"),\n\t\t\t\t argv[0], argv[optind - 1][0], pfound->name);\n\n\t\t      nextchar += strlen (nextchar);\n\n\t\t      optopt = pfound->val;\n\t\t      return '?';\n\t\t    }\n\t\t}\n\t    }\n\t  else if (pfound->has_arg == 1)\n\t    {\n\t      if (optind < argc)\n\t\toptarg = argv[optind++];\n\t      else\n\t\t{\n\t\t  if (opterr)\n\t\t    fprintf (stderr,","sourceCodeStart":698,"sourceCodeEnd":734,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/GPL/DemanglerGnu/src/demangler_gnu_v2_24/c/getopt.c#L698-L734","documentation":"GNU getopt long-option path, the single-dash (or plus) form: when the user writes -option=value or +option=value for a no_argument long option, getopt reports the same condition as the '--' case but with the '%c%s' format (the prefix char '-' or '+' plus the name). Same root cause - a value supplied to a flag that takes none - just for the non-'--' spelling.","triggerScenarios":"Writing -longopt=value or +longopt=value (one dash or plus, attached value) for a long option defined with no_argument. getopt prints argv[0], the leading char, and the option name.","commonSituations":"Using a single-dash long-option spelling (some tools accept -verbose in addition to --verbose) and attaching a value; '+' prefixed options from GNU-style getopt with a stray argument; shell completion or template inserting =value onto a flag.","solutions":["Remove the value: pass -verbose (or prefer the canonical --verbose form).","Verify via --help whether the option accepts an argument at all.","Standardize on the '--' long form to avoid the single-dash ambiguity.","Correct the script/template that appends =value to no-argument flags."],"exampleFix":"# before\n$ tool -verbose=1\n... option `-verbose' doesn't allow an argument\n\n# after\n$ tool -verbose    # or preferably --verbose","handlingStrategy":"validation","validationCode":"// Reject value attachment on single-dash no-argument long options\nif (!optionHasArg(name) && attachedValue != null) {\n    throw new IllegalArgumentException(\"Flag \" + name + \" takes no argument\");\n}","typeGuard":"boolean isValidSingleDashInvocation(String name, String value, Set<String> noArgFlags) {\n    return value == null || !noArgFlags.contains(name);\n}","tryCatchPattern":"int rc = run_child({\"tool\", \"-\" + name + (value != null ? \"=\" + value : \"\")});\nif (rc != 0 && stderr_contains(\"doesn't allow an argument\")) {\n    // retry without the value, or switch to the '--' form\n}","preventionTips":["Avoid single-dash long-option spellings; use '--' to remove ambiguity.","Do not attach values to flags that take none.","Verify the option's argument policy via --help.","Correct scripts that build flags with unconditional =value suffixes."],"tags":["demangler","cli","getopt","arguments","usage"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}