{"record":{"id":"09e5c7a796840fdd","repo":"NationalSecurityAgency/ghidra","slug":"s-option-s-doesn-t-allow-an-argument","errorCode":null,"errorMessage":"%s: option `--%s' doesn't allow an argument","messagePattern":"(.+?): option `--(.+?)' 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":711,"sourceCode":"\t}\n\n      if (pfound != NULL)\n\t{\n\t  option_index = indfound;\n\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)","sourceCodeStart":693,"sourceCodeEnd":729,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/GPL/DemanglerGnu/src/demangler_gnu_v2_24/c/getopt.c#L693-L729","documentation":"GNU getopt long-option path: the user wrote --option=value (or --option value) for a long option whose has_arg is 0 (no_argument). With opterr enabled, getopt prints this and returns '?'. It is a command-line usage error specific to the '--' long-option form.","triggerScenarios":"Attaching a value to a flag-type long option that takes no argument, e.g. --quiet=true or --help=foo where the option is defined with no_argument. getopt detects the '=' or trailing token and reports the option cannot accept an argument.","commonSituations":"Assuming a boolean flag accepts =true/=false (it does not); copying a value form from a different tool whose flag does take an argument; a wrapper script that always appends '=value' to flags; mixing up a flag with a similarly-named option that does take an argument.","solutions":["Drop the argument from the flag: use --quiet, not --quiet=true.","Check --help to confirm whether the option takes an argument.","If a value is genuinely needed, you may be using the wrong option name (find the value-accepting variant).","Fix the wrapper/template that is appending =value to no-argument flags."],"exampleFix":"# before\n$ tool --verbose=yes\n... option `--verbose' doesn't allow an argument\n\n# after - boolean flag takes no value\n$ tool --verbose","handlingStrategy":"validation","validationCode":"// Don't attach =value to known no-argument flags\nboolean takesArg = optionHasArg(\"--\" + name);  // consult the program's option spec\nif (!takesArg && value != null) {\n    throw new IllegalArgumentException(\"Flag --\" + name + \" takes no argument\");\n}","typeGuard":"boolean isValidInvocation(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\n}","preventionTips":["Consult --help to learn which flags accept arguments.","Do not append =true/=false to boolean flags.","Fix templates/wrappers that universally append =value to flags.","Prefer the canonical '--flag' spelling for boolean options."],"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"}